ghc 7.10.2 type families extension doesn't work

倖福魔咒の 提交于 2019-12-23 10:09:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!