Tobi, good question!
I see Vladimir already answered, but I'll throw my own answer in too.

I think you can encode HKTs in MPTCs (MPTCs are just relations on types,
HKTs are just functions on types, and functions are specific kind of
relation [you might run into a problem with HKTs being themselves types
whereas MPTCs are not, bit I think that's avoidable]), but it would be very
difficult to use (or ensure that usage is correct).
Monads require some notion of HKTs to make sense. It's misleading to talk
about "monad" as a type since it's not a type [see note].
"Monad" is a sort of behavior a type could exhibit (demonstrated by being
an instance of the Monad type class).
It so happens that to exhibit the behavior of "Monad" requires a type to
have kind * -> * (because Monads are generic in their result type).

I would consider HKTs a much better choice than MPTCs (even if MPTCs
theoretically subsume HKTs). They're *way* easier to use.

[note] Strictly speaking, you can have a type "monad" if you have a
sufficiently powerful type system (i.e. some level of dependent types).


On Fri, Feb 28, 2014 at 2:54 PM, Tobias Müller <[email protected]> wrote:

> Eric Reed <[email protected]> wrote:
> > In general, monads require higher-kinded types because for a type to be a
> > monad it must take a type variable. That is, Option<T> and List<T> could
> > be monads, but int and TcpSocket can't be monads. So imagine we wanted to
> > define a trait Monad in Rust.
>
> Just for my understanding. Is there an inherent reason that a monad has to
> be a higher kinded type (type constructor)? Couldn't it also be represented
> somehow as a multiparam trait/typeclass?
> AFAIK, higher kinded types are standard haskell, while MPTCs are not, so
> it's the obvious choice for haskell. Is it also for rust?
>
> Tobi
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to