Hi Brent,
I'm sorry to hear that the non-injectivity issue bit you. It's bitten
me also at times, leading me to choose associated data types (injective)
instead of associated synonyms (potentially non-injective). And
sometimes, the data types route is problematic, as the new types aren't
instances (and I don't know how to declare them to be) of other classes when I need them to be. MemoTrie & vector-space seem to
trip over these issues, and I thought I'd lucked into a combo that
worked, but from your note I guess I just hadn't pushed far enough to
uncover difficulties.
I'm unsure now, but I think I tried making
Basis a data type (not syn) and ran into the problem I mentioned above. The Basis *synonyms* also have HasTrie instances, which is crucially important. If we switch to (injective) data types, then we lose the HasTrie instances. I'd be okay with defining HasTrie instances (preferably via "deriving") for the associated Basis data types, but I couldn't figure out how to. Maybe it's not possible currently, or maybe I just didn't know how.
I'd love to have help exploring these issues more widely & deeply, as they do seem to fatally wound the usefulness of associated data types.
- Conal
On Thu, Apr 15, 2010 at 12:48:20AM +1000, Roman Leshchinskiy wrote:Aha! That's what I was missing. Thanks for the insight, Roman. I
>
> >
> > Right, this seems weird to me. Why is there still a 'u' mentioned in
> > the constraints? Actually, I don't even see why there ought to be
> > both v and v1. The type of (*.*) mentions three type variables, u, v, and w:
> >
> > (*.*) :: (HasBasis u, HasTrie (Basis u),
> > HasBasis v, HasTrie (Basis v),
> > VectorSpace w,
> > Scalar v ~ Scalar w)
> > => (v :-* w) -> (u :-* v) -> u :-* w
>
> Note that (:-*) is a type synonym:
>
> type :-* u v = MSum (Basis u :->: v)
guess it's time to go bug Conal... =)
-Brent
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe