[Haskell-cafe] type versus data declarations
Alfonso Acosta
alfonso.acosta at gmail.com
Fri Jun 8 06:25:34 EDT 2007
Hola Emilio!
On 6/7/07, Emilio Jesús Gallego Arias <egallego at babel.ls.fi.upm.es> wrote:
> 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)
type only works for redefinitions (i.e. adding the |Show a| constraint
makes FSet a different type to (a -> Double)).
In addition you seem to be trying to pack a dictionary with the type
(something you cannot do in Haskell without existentials). This is
just a guess, but it seems that a definition using existentials is
what you're looking for.
data FSet a = forall a. Show a => FSet (a -> Double)
Cheers,
PD: Saluda Ángel de mi parte :)
More information about the Haskell-Cafe
mailing list