[Haskell-cafe] Displaying infered type signature of
'offside'functions
Stefan O'Rear
stefanor at cox.net
Sun Apr 29 20:10:30 EDT 2007
On Sun, Apr 29, 2007 at 07:03:32PM -0500, Antoine Latter wrote:
> This looks like a good place to ask a question that's been bugging me for a
> bit:
>
> I've had cases in my own code where I can't seem to create a type annotation
> for an "inner" declaration that the type-checker likes. Here's a toy
> example:
>
> In the following code:
>
> >applyfunc :: (a -> b -> c) -> a -> b -> c
> >applyfunc f x y = doit y where
> > doit = f x
>
> What type annotation can I successfully apply to the function "doit"?
There isn't one, plain and simple. However, if you allow GHC
extensions, you can:
{-# Language ScopedTypeVariables #-}
applyfunc :: forall a b c . (a -> b -> c) -> a -> b -> c
applyfunc f x y = doit y where
doit :: b -> c
doit = f x
The 'forall' serves no other purpose than to deliberately break
haskell 98 compatibility.
Stefan
More information about the Haskell-Cafe
mailing list