Haskell类型类:类型错误

时间:2016-02-11 04:24:57

标签: json parsing haskell types typeclass

我正在尝试编写一个小玩具JSON解析器。为此,我创建了一个表示有效JSON值的Value类型和一个类型类Deserial a,它表示类型a从Value类型反序列化为类型{{1}的能力}}。

但是,当我尝试在我的类型上运行a函数时,我收到类型错误:

deserialize

我知道反序列化的逻辑是有效的,因为"非类型类型版本"工作中。但是,我是haskell的新手,不知道我对Deserial类型类的定义有什么不对。任何帮助将不胜感激!

No instance for (Deserial a0) arising from a use of deserialize
The type variable a0 is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there is a potential instance available:
  instance Deserial Person -- Defined at json.hs:33:10
In the expression: deserialize jason
In an equation for `deserialized': deserialized = deserialize jason

0 个答案:

没有答案
相关问题