I have two functions for controlling loops, continue
and break
:
type Control a = (a -> a) -> a -> a
continue :: Control a
continue = id
break :: Control a
break = const id
Then, I wanted to simplify the Control
type synonym. Hence, I wrote:
type Endo a = a -> a
type Control a = Endo (Endo a)
continue :: Control a
continue = id
break :: Control a
break = const id
However, when I tried to further simplify it I got an error:
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’
I don't understand why I am getting this error. Perhaps you could enlighten me.
Duplicate Endo a
is valid ifEndo
is adata
ornewtype
, but not if it's just atype
. – Pogonia