ghc 7.10.2类型的家庭扩展不起作用 [英] ghc 7.10.2 type families extension doesn't work

查看:97
本文介绍了ghc 7.10.2类型的家庭扩展不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在GHC 7.10.2中尝试以下示例时,我在输入'where'时得到解析错误:

  { - #LANGUAGE TypeFamilies# - } 

类型F a :: *
类型实例其中
F(Maybe Int )= Int
F(Maybe Bool)= Bool
F(也许a)= String

两年前,同样的问题被问到关于GHC 7.4.2



我今年使用的是GHC 7.6。*类型系列(不记得最后一位数字)。是GHC 7.10.2的问题吗?



根据用户指南,可以使用类型系列。



我的GHC 7.10.2和cabal 1.22 .6.0从此PPA 安装。

解决方案

你不能混合这样的开放和封闭类型的语法,我不确定你从哪里得到这个想法。正确的语法是

  type family F a :: *其中
F(Maybe Int)= Int
(可能Bool)= Bool
F(也许a)=字符串


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.

解决方案

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

这篇关于ghc 7.10.2类型的家庭扩展不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆