On Wed, Aug 01, 2007 at 07:57:48AM +0200, Wolfgang Lux wrote: > Jim Apple wrote: > >> data Rec f = In (f (Rec f)) >> type P f a = f (Rec f, a) >> >> mapP :: Functor f => (a -> b) -> P f a -> P f b >> mapP g = fmap (\(x,a) -> (x, g a)) >> >> instance Functor f => Functor (P f) where >> fmap = mapP >> >> Why did Gofer have this power while Haskell does not? > > Haskell does have the same power as Gofer, it simply does > not allow you to define instances for type synonyms (just > in order to prevent overlapping instances, I guess). If > you use a newtype instead of a type synonym everything > works fine:
Quite probably they never bothered to test it. [EMAIL PROTECTED]:/usr/local/src/gofer$ tail -15 standard.prelude openfile f = primFopen f (error ("can't open file "++f)) id -- End of Gofer standard prelude: -------------------------------------------- class Functor f where fmap :: (a -> b) -> f a -> f b data Rec f = In (f (Rec f)) type P f a = f (Rec f, a) mapP :: Functor f => (a -> b) -> P f a -> P f b mapP g = fmap (\(x,a) -> (x, g a)) instance Functor f => Functor (P f) where fmap = mapP [EMAIL PROTECTED]:/usr/local/src/gofer$ src/gofer Gofer Version 2.30b Copyright (c) Mark P Jones 1991-1995 Reading script file "standard.prelude": ERROR "standard.prelude" (line 874): Not enough arguments for type synonym "P" FATAL ERROR: Unable to load prelude [EMAIL PROTECTED]:/usr/local/src/gofer$ Stefan
signature.asc
Description: Digital signature
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell