Hi again, is there a way in some haskell extension to explicit (system F's) big lambdas and (term Type) applications in order to help type inference? If not: is there a way to provide ghc directly with core code before the type checking phase? Paul
Hi Paul, You should be able to introduce \Lambda at the source level by writing a type signature with an explicit "forall". Similarly you can then instantiate these \Lambdas by using a type signature which is an instance of the foralled type at the use site: ~~~ -- id will get a \Lambda in Core id :: forall a. a -> a id x = x -- this use of id will have Int applied as the first type argument in Core main = print $ (id :: Int -> Int) 10 ~~~ This *should* extend smoothly to RankNTypes and other situations where GHC can't do good type inference. The typechecker doesn't know about big lambdas (they are added to Core by the desugarer from the output of the typechecker) so there is no better way to do this AFAIK. Cheers, Max On 18 March 2010 15:07, Paul Brauner <paul.brauner@loria.fr> wrote:
Hi again,
is there a way in some haskell extension to explicit (system F's) big lambdas and (term Type) applications in order to help type inference?
If not: is there a way to provide ghc directly with core code before the type checking phase?
Paul _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Alternatively: let f :: <some type involving a> f = ... f' :: a -> <some type involving a> f' _ = f in f' (undefined :: Int) <normal f arguments> On Thu, Mar 18, 2010 at 12:10 PM, Max Bolingbroke <batterseapower@hotmail.com> wrote:
Hi Paul,
You should be able to introduce \Lambda at the source level by writing a type signature with an explicit "forall". Similarly you can then instantiate these \Lambdas by using a type signature which is an instance of the foralled type at the use site:
~~~ -- id will get a \Lambda in Core id :: forall a. a -> a id x = x
-- this use of id will have Int applied as the first type argument in Core main = print $ (id :: Int -> Int) 10 ~~~
This *should* extend smoothly to RankNTypes and other situations where GHC can't do good type inference.
The typechecker doesn't know about big lambdas (they are added to Core by the desugarer from the output of the typechecker) so there is no better way to do this AFAIK.
Cheers, Max
On 18 March 2010 15:07, Paul Brauner <paul.brauner@loria.fr> wrote:
Hi again,
is there a way in some haskell extension to explicit (system F's) big lambdas and (term Type) applications in order to help type inference?
If not: is there a way to provide ghc directly with core code before the type checking phase?
Paul _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
On Fri, Mar 19, 2010 at 4:03 AM, Nicolas Frisby <nicolas.frisby@gmail.com> wrote:
Alternatively:
let f :: <some type involving a> f = ...
f' :: a -> <some type involving a> f' _ = f in f' (undefined :: Int) <normal f arguments>
Or use Edward Kmett's tagged library: http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged.... so you don't have to use bottom values: let f :: <some type involving a> f = ... f' :: Tagged a <some type involving a> f' = Tagged f regards, Bas
Thanks to all! Paul On Fri, Mar 19, 2010 at 04:24:17PM +0100, Bas van Dijk wrote:
On Fri, Mar 19, 2010 at 4:03 AM, Nicolas Frisby <nicolas.frisby@gmail.com> wrote:
Alternatively:
let f :: <some type involving a> f = ...
f' :: a -> <some type involving a> f' _ = f in f' (undefined :: Int) <normal f arguments>
Or use Edward Kmett's tagged library:
http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged....
so you don't have to use bottom values:
let f :: <some type involving a> f = ...
f' :: Tagged a <some type involving a> f' = Tagged f
regards,
Bas _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Bas van Dijk -
Max Bolingbroke -
Nicolas Frisby -
Paul Brauner