[Haskell-cafe] It matters how Type Synonyms are defined?

Bryan Burgers bryan.burgers at gmail.com
Fri Feb 2 17:18:19 EST 2007


Today, I was plugging away on a program and I ran into a problem. It
seems that ErrorT can or can not take a type synonym as its monad,
depending on how the type synonym was defined. For example, consider
this GHCi interactive run:

> :k Maybe
Maybe :: * -> *
> let { a :: ErrorT String Maybe Bool; a = undefined }
> :t a
a :: ErrorT String Maybe Bool

> :k State (Scope VVar)
State (Scope VVar) :: * -> *
> let { a :: ErrorT String (State (Scope VVar)) Bool; a = undefined }
> :t a
a :: ErrorT String (State (Scope VVar)) Bool

ScopeState is defined in a file as:
> type ScopeState a = State (Scope VVar) a

> :k ScopeState
ScopeState :: * -> *
> let { a :: ErrorT String ScopeState Bool; a = undefined }

<interactive>:1:6:
    Type synonym `ScopeState' should have 1 argument, but has been given 0
    In the type signature: a :: ErrorT String ScopeState Bool

Now, I was going to ask something like, "How can I define my type
synonym so I can do this," but I figured out while writing this email
that if I define ScopeState a different way:
> type ScopeState = State (Scope VVar)

> :k ScopeState
ScopeState :: * -> *
> let { a :: ErrorT String ScopeState Bool; a = undefined }
> :t a
a :: ErrorT String ScopeState Bool

So, my new question is: Why does it matter how ScopeState is defined?

Bryan Burgers


More information about the Haskell-Cafe mailing list