Haskell、Control.Lens:无法将类型“[Language.Haskell.TH.Syntax.Dec]”与“Language.Haskell.TH.Syntax.Exp”匹配
Haskell, Control.Lens: Couldn't match type ‘[Language.Haskell.TH.Syntax.Dec]’ with ‘Language.Haskell.TH.Syntax.Exp’
我想学习如何使用 Control.Lens
包。我尝试使用 an official tutorial.
首先,我没有Control.Lens.Tutorial
包。重现示例很重要吗?
我启动了 GHCi 并加载了模板Haskell 扩展:
Prelude> :set -XTemplateHaskell
然后我尝试重现教程的第一步:
Prelude> import Control.Lens hiding (element)
Prelude Control.Lens> import Control.Lens.TH
Prelude Control.Lens Control.Lens.TH>
Prelude Control.Lens Control.Lens.TH> data Point = Point { _x :: Double, _y :: Double } deriving (Show)
Prelude Control.Lens Control.Lens.TH> data Atom = Atom { _element :: String, _point :: Point } deriving (Show)
Prelude Control.Lens Control.Lens.TH> $(makeLenses ''Point)
出现错误:
<interactive>:7:3: error:
• Couldn't match type ‘[Language.Haskell.TH.Syntax.Dec]’
with ‘Language.Haskell.TH.Syntax.Exp’
Expected type: Language.Haskell.TH.Lib.Internal.ExpQ
Actual type: Language.Haskell.TH.Lib.Internal.DecsQ
• In the expression: makeLenses ''Point
In the untyped splice: $(makeLenses ''Point)
GHC 8.6.4,镜头 4.19.2 从 Cabal 安装。
教程是不是有点过时了?如果是,我在哪里可以阅读 Haskell 中关于镜头的实用介绍,其中包含简单的使用示例和尽可能少的范畴论?
:{
data Point = Point { _x :: Double, _y :: Double } deriving (Show)
data Atom = Atom { _element :: String, _point :: Point } deriving (Show)
makeLenses ''Point
:}
我想学习如何使用 Control.Lens
包。我尝试使用 an official tutorial.
首先,我没有Control.Lens.Tutorial
包。重现示例很重要吗?
我启动了 GHCi 并加载了模板Haskell 扩展:
Prelude> :set -XTemplateHaskell
然后我尝试重现教程的第一步:
Prelude> import Control.Lens hiding (element)
Prelude Control.Lens> import Control.Lens.TH
Prelude Control.Lens Control.Lens.TH>
Prelude Control.Lens Control.Lens.TH> data Point = Point { _x :: Double, _y :: Double } deriving (Show)
Prelude Control.Lens Control.Lens.TH> data Atom = Atom { _element :: String, _point :: Point } deriving (Show)
Prelude Control.Lens Control.Lens.TH> $(makeLenses ''Point)
出现错误:
<interactive>:7:3: error:
• Couldn't match type ‘[Language.Haskell.TH.Syntax.Dec]’
with ‘Language.Haskell.TH.Syntax.Exp’
Expected type: Language.Haskell.TH.Lib.Internal.ExpQ
Actual type: Language.Haskell.TH.Lib.Internal.DecsQ
• In the expression: makeLenses ''Point
In the untyped splice: $(makeLenses ''Point)
GHC 8.6.4,镜头 4.19.2 从 Cabal 安装。
教程是不是有点过时了?如果是,我在哪里可以阅读 Haskell 中关于镜头的实用介绍,其中包含简单的使用示例和尽可能少的范畴论?
:{
data Point = Point { _x :: Double, _y :: Double } deriving (Show)
data Atom = Atom { _element :: String, _point :: Point } deriving (Show)
makeLenses ''Point
:}