
You should be able to write something like this:
type StateB a b = StateT SomeOtherState (StateA a) b
Thank you for reply, but this variant actually does not compile: StateA and (StateA a) have different kinds. Dmitry
Best regards, Øystein Kolsrud
On Wed, Dec 7, 2011 at 11:48 AM, Dmitry Kulagin
wrote: Hi Dan,
I am still pretty new in Haskell, but this problem annoys me already.
If I define certain monad as a type synonym:
type StateA a = StateT SomeState SomeMonad a
Then I can't declare new monad based on the synonym:
type StateB a = StateT SomeOtherState StateA a
The only way I know to overcome is to declare StateA without `a':
type StateA = StateT SomeState SomeMonad
But it is not always possible with existing code base.
I am sorry, if this is offtopic, but it seemed to me that the problem is realted to partially applied type synomyms you described.
Thanks! Dmitry
On Tue, Dec 6, 2011 at 10:59 PM, Dan Doel
wrote: Greetings,
In the process of working on a Haskell-alike language recently, Ed Kmett and I realized that we had (without really thinking about it) implemented type synonyms that are a bit more liberal than GHC's. With LiberalTypeSynonyms enabled, GHC allows:
type Foo a b = b -> a type Bar f = f String Int
baz :: Bar Foo baz = show
because Bar expands to saturate Foo. However, we had also implemented the following, which fails in GHC:
type Foo a b = b -> a type Bar f = f (Foo Int) (Foo Int) type Baz f g = f Int -> g Int
quux :: Bar Baz quux = id
That is: type synonyms are allowed to be partially applied within other type synonyms, as long as similar transitive saturation guarantees are met during their use.
I don't know how useful it is, but I was curious if anyone can see anything wrong with allowing this (it seems okay to me after a little thought), and thought I'd float the idea out to the GHC developers, in case they're interested in picking it up.
-- Dan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Mvh Øystein Kolsrud