问题
I'm getting parse error on input ‘where’
when trying the following example in GHC 7.10.2:
{-# LANGUAGE TypeFamilies #-}
type family F a :: *
type instance where
F (Maybe Int) = Int
F (Maybe Bool) = Bool
F (Maybe a) = String
Same question was asked two years ago about GHC 7.4.2.
I used type families fine with GHC 7.6.* (can't remember last digit) this year. Is it a problem with GHC 7.10.2?
According to the User's Guide, type families are available.
My GHC 7.10.2 and cabal 1.22.6.0 where installed from this PPA.
回答1:
You can't mix open and closed type family syntax like this, and I'm not sure where you are getting that idea from. The correct syntax is
type family F a :: * where
F (Maybe Int) = Int
F (Maybe Bool) = Bool
F (Maybe a) = String
来源:https://stackoverflow.com/questions/32211822/ghc-7-10-2-type-families-extension-doesnt-work