[Haskell-cafe] type versus data declarations

Emilio Jesús Gallego Arias egallego at babel.ls.fi.upm.es
Thu Jun 7 14:03:30 EDT 2007


Hello,

I'm wondering why you can write

> data FSet a = Show a => M (a -> Double)
>
> a :: FSet Double
> a = M $ \x -> 0

and it works, but

> type FSet a = Show a => (a -> Double)
>
> a :: FSet Double
> a _ = 0

fails with

> All of the type variables in the constraint `Show a' are already in scope
>    (at least one must be universally quantified here)
> In the type synonym declaration for `FSet'

If I understood the GHC manual, this should work, as FSet a should be
replaced in a, so a type signature would come:

> a :: Show a => (a -> Double)

which is OK.

Sorry if this is FAQ, but I did some searches and nothing came out.

Thanks in advance,

Emilio



More information about the Haskell-Cafe mailing list