Re: [Haskell] Rank-N types with (.) composition

2015-02-11 Thread Simon Peyton Jones
| To: Dan Doel | Cc: haskell@haskell.org | Subject: Re: [Haskell] Rank-N types with (.) composition | | On February 10, 2015 16:28:56 Dan Doel wrote: | > Impredicativity, with regard to type theories, generally refers to | > types being able to quantify over the collection of types th

Re: [Haskell] Rank-N types with (.) composition

2015-02-11 Thread Henning Thielemann
On Tue, 10 Feb 2015, Tyson Whitehead wrote: I came across something that seems a bit strange to me. Here is a simplified version (the original was trying to move from a lens ReifiedFold to a lens-action ReifiedMonadicFold) You are on Haskell@haskell.org here. Could you please move to haske

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Tyson Whitehead
On February 10, 2015 17:44:54 Dan Doel wrote: > Really, I think the least ad-hoc solution (other than a hypothetical > best-of-both-worlds inference algorithm) would be to allow code like: > > runST do ... > > where you can apply expressions directly to certain syntactic constructs > without

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Dan Doel
There is no special type for ($). The name is simply special cased in the compiler. The rule is something like: Whenever you see: f Prelude.$ x instead try to type check: f x That may not be the exact behavior, but it's close. To fix (.) (in a similar fashion) you would have to have a sim

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Brandon Allbery
On Tue, Feb 10, 2015 at 6:19 PM, Tyson Whitehead wrote: > Out of curiosity, how would you write the special internal type that ($) > has that separates it from ($') above? I don't think there's any way to write the type. Remember that GHC uses System Fc internally; that can represent more types

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Tyson Whitehead
On February 10, 2015 16:28:56 Dan Doel wrote: > Impredicativity, with regard to type theories, generally refers to types > being able to quantify over the collection of types that they are then a > part of. So, the judgment: > > (forall (a :: *). a -> a) :: * > > is impredicative, because we

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Dan Doel
Well, that might also be surprising, unless ($) is also magically made to work like a standard operator (just off the top of my head; there may be other confusing aspects). Really, I think the least ad-hoc solution (other than a hypothetical best-of-both-worlds inference algorithm) would be to all

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread David Feuer
On Tue, Feb 10, 2015 at 4:28 PM, Dan Doel wrote: > Also, I think ($) is the way it is specifically because 'runST $ ...' is > considered useful and common enough to warrant an ad-hoc solution. There > have been other ad-hoc solutions in the past, but redesigning inference to > not be ad-hoc about

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread Dan Doel
Impredicativity, with regard to type theories, generally refers to types being able to quantify over the collection of types that they are then a part of. So, the judgment: (forall (a :: *). a -> a) :: * is impredicative, because we have a type in * that quantifies over all types in *, which

Re: [Haskell] Rank-N types with (.) composition

2015-02-10 Thread David Feuer
The problem is that GHC's type system is (almost entirely) predicative. I couldn't tell you just what that means, but to a first approximation, it means that type variables cannot be instantiated to polymorphic types. You write trip = Wrap . extract which means (.) Wrap extract (.)::(b->c)->(a

[Haskell] Rank-N types with (.) composition

2015-02-10 Thread Tyson Whitehead
I came across something that seems a bit strange to me. Here is a simplified version (the original was trying to move from a lens ReifiedFold to a lens-action ReifiedMonadicFold) {-# LANGUAGE RankNTypes #-} import Control.Applicative newtype Wrap = Wrap { extract :: forall f. Functor f =>