我想试用 Haskelltype
并data
使用以下代码
type Program a = Maybe a -> (Operation a, Maybe Program a)
data Operation a = Read a | Write a
Program
遵循延续传递风格 (CPS) 并Nothing
表示终止。a
可以用Int
或其他东西实例化。
然而,GHC 抱怨说:
main.hs:1:1:
Cycle in type synonym declarations:
main.hs:1:1-58: type Program a =
Maybe a -> (Operation a, Maybe Program a)
我是 Haskell 的新手,所以我不明白为什么不允许这样做。如何在 Haskell 中表达这种类型?