Changes between Version 2 and Version 3 of NewAxioms/DiscussionPage


Ignore:
Timestamp:
Jun 1, 2012 5:36:09 AM (3 years ago)
Author:
AntC
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NewAxioms/DiscussionPage

    v2 v3  
    2121}}}
    2222
    23   (Section 3.3 Transltion of the draft design/Law 3.5 (Consistent instances) seems to be saying multiple groupings are OK. An example would make it clearer.)
     23  (Section 3.3 Transltion of the draft design/Law 3.6 (Consistent instance groups) seems to be saying multiple groupings are OK. An example would make it clearer.)
    2424
    2525 * Are there any rules/validation around the sequence of patterns within a grouping?
    2626
    2727  If a later pattern is more specific than an earlier (so could never get selected) is that pattern flagged, or just (in effect) silently ignored?
     28
     29 * Must there be a most general pattern? (By most general, I mean exactly matching the instance head. Presumably it would appear last in the group.)
     30
     31  If not, presumably at a use site type inference could fail to find a match. For example:
     32
     33{{{
     34type instance G a b where
     35    G (c, d) Int = c
     36    G Bool b     = b
     37-- stop there
     38
     39g :: G Int Int               -- what happens now?
     40}}}
     41
     42 * Can inference get 'stuck'? (I'm guessing so. See the groundedness issues in the '''HList''' paper, at beginning of Section 9.)
     43
     44  For example, at a use site for `F a b`, we can infer `a ~ Int` and `b ~ (Num b0) => b0`, but we can't refine `b` any further. So we don't have sufficient evidence to match pattern `F a a = True`; but neither can we move on to pattern `F a b = False`.
     45
     46
    2847
    2948== Suggestions ==
     
    96115   * One downside is that you have to provide a translation instance for each user-defined type, and make sure the representation doesn't clash with any other type. Template Haskell helps, compiler support would be better.
    97116
     117  (By the way, arguably the whole TTypeable project might have been unnecessary. Oleg built the approach because of persistent trouble around overlaps. But you can't do overlaps without fundeps (in any yet availabe version of GHC -- and Hugs is far worse.) Perhaps the trouble was really because of fundeps interfering with overlap? http://www.haskell.org/pipermail/haskell-prime/2012-May/003688.html As and when matching coercions are available, we'll be able to experiment.)
     118
    98119== Comments ==
    99120
     
    107128 * '''Sudden and Silent Overlap:''' a newly-imported module or package might declare an instance (for a type class, especially a library class) that is more specific than any you've been working with. The program's behaviour may suddenly change for no (apparent) reason.
    108129
    109   (??The original Monad Transformers approach suffered from this. The design deliberately had a most general instance declared with the class. Application modules overrode it.)
     130  (??The original Monad Transformers approach suffered from this. The design deliberately had a most general instance declared with the class. Application modules overrode it. See '''Type Classes: Exploring the design space''' Jones/Jones/Meijer 1997, section 3.6.2)
    110131
     132 * '''Undecidability:''' presumably the UndecidableInstances option is still applicable, with all the issues around termination and coverage conditions. Are there any additional considerations raised by overlaps/matching coercions?
    111133
    112134== Example Applications/Uses for Instance Overlap ==