我有两个用于控制循环的功能,continue
并且break
:
type Control a = (a -> a) -> a -> a
continue :: Control a
continue = id
break :: Control a
break = const id
然后,我想简化Control
类型同义词。因此,我写道:
type Endo a = a -> a
type Control a = Endo (Endo a)
continue :: Control a
continue = id
break :: Control a
break = const id
然而,当我试图进一步简化它时,我得到了一个错误:
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
Prelude> type Endo a = a -> a
Prelude> type Duplicate w a = w (w a)
Prelude> type Control a = Duplicate Endo a
<interactive>:4:1:
Type synonym ‘Endo’ should have 1 argument, but has been given none
In the type declaration for ‘Control’
我不明白为什么我会收到这个错误。也许你可以启发我。