Thanks, so far I’ve just gone through Apoorv’s talk. I can see some reasons this isn’t getting much traction …
- Asking “Was the AMP a good idea?” [Apoorv’s next-to-next-to-last slide]. Do we really want to go through all that library restructuring again?
- “dirty details” [next-to-last slide] I’m getting a fishy smell – as in fishhooks.
- How do we avoid carrying class/constraint dictionaries around the place? (What’s more the
(@)
is a methodless dictionary/only there to compile-time verify the code, but it carries constraint dictionaries.) - Because I think the proposed approach is just plain wrong: a large proportion of those dictionaries/constraints are unnecessary; and the 1999 SPJ mail thread I linked above explains why:
pattern-matching on MkT [SPJ thought of] as eliminating a constraint.
But since the dictionary isn’t stored in the constructor we can’t eliminate it.)** I therefore PROPOSE that when pattern matching on a constructor,
** any context on the data type declaration is ignored.
With constructor classes (like instance Functor Set
, where output Set b
wants Ord b
), we in general need an Ord
dictionary inside the fmap
: whatever morphing fmap
is applying, we can’t rely on it preserving the relative ordering of elements. OTOH we don’t want an Ord
dictionary for the incoming Set a
, because fmap
isn’t interested in whatever order the incoming elements are in.
I should mention that unlike in 2010 when DatatypeContexts
were taken away, we now have PatternSynonyms
that can require constraints for building but not matching (with that double Foo a => Bar a => ...
business). So a supplier of a datatype can make the real constructors abstract; export only the synonyms. (I wish Set
would do that: it does indeed make the constructors abstract; but provides a bunch of functions (with Ord
constraints) for building; most access you have to stream to a List
; a PattSyn for lookup within a pattern would be lovely.)
And apologies to @jon if I’m hijacking the thread: I think previous answers concluded the q; if you want more discussion around the o.p. I’ll start a new thread.