haskell - Type Families extension does not work as described -


on the haskell wiki page type families, there following list of examples:

type family f :: * type instance f [int]              = int         -- ok! type instance f string             = char        -- ok! type instance f (f a)              =           -- wrong: type parameter mentions type family type instance f (forall a. (a, b)) = b           -- wrong: forall type appears in type parameter type instance f float              = forall a.a  -- wrong: right-hand side may not forall type type instance                              -- ok!   f (maybe int)  = int   f (maybe bool) = bool   f (maybe a)    = string type instance            -- wrong: conflicts earlier instances (see below)   f int = float   f   = [a]  type family g b :: * -> * type instance g int            = (,)     -- wrong: must 2 type parameters type instance g int char float = double  -- wrong: must 2 type parameters 

this demonstrates type instance where valid syntax under extension. following code not compile me ghc 7.4.2:

{-# language typefamilies #-}  type family f :: * type instance   f (maybe int)  = int   f (maybe bool) = bool   f (maybe a)    = string 

the error message is:

test.hs:4:15: parse error on input `where'

since parsing error, looks syntax not supported, missing requisite extension, or else amiss?

this appears case of premature documentation. according this blog post, syntax part of feature added ghc head, it's not yet valid in released version of ghc.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -