[Haskell-cafe] Re: Parametrized monads
ashley at semantic.org
Mon Jun 15 17:25:49 EDT 2009
Miguel Mitrofanov wrote:
> Suppose I want to create a specific monad as a combination of monad
> transformers - something like "StateT smth1 (ReaderT smth2 Identity)".
> As you can see, each transformer is parametrized with a type of kind *.
> I want to abstract these parameters, so that instead of "StateT smth..."
> I can write something like
> Zip (ConsT StateT (ConsT ReaderT NilT)) (ConsA smth1 (ConsA smth2 NilA))
> and it would be a type isomorphic to the first one. I mean, I want
> (ConsT StateT (ConsT ReaderT NilT))" to be a separate entity of fixed
> kind, so that I can, say, create a class instance for it or something.
> I'd be quite happy if list length appears as a separate parameter, like
> Zip (Succ (Succ Zero)) (ConsT ...
> I would NOT be happy with something like
> Zip (List_2 StateT ReaderT) (Arg_2 smth1 smth2)
> If haskell had polymorphic kinds, I'd be able to do it easily;
> unfortunately, it doesn't have them.
I think the "type families" extension can do this.
More information about the Haskell-Cafe