Changes between Version 7 and Version 8 of Defaulting


Ignore:
Timestamp:
Nov 21, 2006 1:14:47 PM (9 years ago)
Author:
malcolm.wallace@…
Comment:

note about confluence in the MPTC case

Legend:

Unmodified
Added
Removed
Modified
  • Defaulting

    v7 v8  
    140140That is, there is a single unique relation between types that can be chosen if ''all'' of its variables are otherwise unconstrained.
    141141
    142 Open questions: if some of the variables are already resolved to actual types, is it OK to default the remaining variables?  Assuming the resolved types are in the default relation anyway?  What if the already-resolved types are not in the default relation?  Would anyone ever want to use defaulting to choose different types depending on what other types have already beeen resolved?
     142Open questions: if some of the variables are already resolved to actual types, is it OK to default the remaining variables?  Assuming the resolved types are in the default relation anyway?  What if the already-resolved types are not in the default relation?  Would anyone ever want to use defaulting to choose different types depending on what other types have already been resolved?
     143
     144What happens if the choice of default types is not confluent?  For example:
     145{{{
     146instance Foo Float Integer
     147instance Foo Double Int
     148default Fractional Double
     149default Num Integer
     150(Fractional a, Foo a b, Num b) => e
     151}}}
     152Here, if you choose 'a' first, using the default Fractional Double, then because you have an instance of Foo Double Int, then 'b' must be Int.  But if you choose 'b' first, using the default Num Integer, then because you have an instance Foo Float Integer, then 'a' must be Float.  One suggestion might be that defaulting will only occur if the results are confluent, i.e. the compiler should try all possible orderings in
     153which to default variables, and if they do not come up with the same
     154answer, then reject the program.
    143155
    144156=== Pros ===
     
    149161
    150162=== Cons ===
    151  * not sure if this exactly captures the existing Haskell'98 module (but because defaults are currently limited to Prelude classes, it probably does).
     163 * not sure if this exactly captures the existing Haskell'98 module (but because defaults are currently limited to Prelude classes, it probably does)
     164 * the story for MPTC is not altogether clear yet
     165
    152166
    153167== Proposal 3 - global scope ==