[Haskell-cafe] Re: Monad instance for partially applied type constructor?

Gábor Lehel illissius at gmail.com
Wed Sep 29 17:43:48 EDT 2010

On Wed, Sep 29, 2010 at 11:15 PM, DavidA <polyomino at f2s.com> wrote:
> Ryan Ingram <ryani.spam <at> gmail.com> writes:
>> Haskell doesn't have true type functions; what you are really saying is
>> instance Monad (\v -> Vect k (Monomial v))
> Yes, that is exactly what I am trying to say. And since I'm not allowed to say
> it like that, I was trying to say it using a type synonym parameterised over v
> instead. It appears that GHC won't let you use partially applied type synonyms
> as type constructors for instance declarations. Is this simply because the GHC
> developers didn't think anyone would want to, or is there some theoretical
> reason why it's hard, or a bad idea?

The version of the lambda calculus (System Fc) GHC uses for its
internal representation doesn't support lambdas at the type level.
I've bumped up against this limitation myself, and don't know of any
way to 'cheat' it (which makes sense, given that it's so fundamental).
You can use newtypes, and recursive definitions (sometimes with
overlap and/or fundeps) work for some cases, though they can get quite
nasty in the harder ones. I have to assume upgrading the type system
to support this would highly nontrivial, though I don't know exactly
how high, nor what drawbacks there might be.

> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Work is punishment for failing to procrastinate effectively.

More information about the Haskell-Cafe mailing list