我正在尝试在Idris中推导Show,Eq,Ord等,但是以下试验均无效:
足迹1:
data Expr =
Lit Int
| Neg Expr
| Add Expr Expr
deriving (Show)
得到:
deriving.idr:5:15-18:
|
5 | deriving (Show)
| ~~~~
When checking type of Main.Add:
Type mismatch between
Type -> Type (Type of Show)
and
Type (Expected type)
足迹2:
data Expr =
Lit Int
| Neg Expr
| Add Expr Expr
deriving (Show _)
得到:
*deriving> Lit 1
Lit 1 : Expr
*deriving> Add (Lit 1) (Lit 1)
(input):Can't infer argument ty to Add, Can't infer argument deriving to Add
足迹3:
data Expr =
Lit Int
| Neg Expr
| Add Expr Expr
deriving (Show Expr)
得到:
*deriving> Lit 1
Lit 1 : Expr
*deriving> Add (Lit 1) (Lit 1)
(input):Can't infer argument deriving to Add
我已经在http://docs.idris-lang.org/和google上甚至在test /目录下的idris-dev存储库中搜索了关键字deriving
,但是没有关于使用idris的用法的演示。有人可以帮忙吗?