Changes between Version 16 and Version 17 of FunctionalDependencies
 Timestamp:
 Apr 7, 2006 9:45:59 AM (11 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

FunctionalDependencies
v16 v17 99 99 100 100 They thus accept instances like the above `MonadWriter` example. 101 Unfortunately, this relaxation breaks the guarantees of termination and coherence :101 Unfortunately, this relaxation breaks the guarantees of termination and coherence. 102 102 103 '''Loss of termination''':: 104 The following instances (CHR paper, ex. 6) seem reasonable: 105 {{{ 103 === Loss of termination === 104 105 The following instances (CHR paper, ex. 6) seem reasonable: 106 {{{ 106 107 class Mul a b c  a b > c where 107 108 (.*.) :: a > b > c … … 111 112 instance Mul a b c => Mul a [b] [c] where x .*. v = map (x.*.) v 112 113 }}} 113 114 114 and yet instance inference fails to terminate for the following (erroneous) definition: 115 {{{ 115 116 f = \ b x y > if b then x .*. [y] else y 116 117 }}} 117 118 118 '''Loss of confluence''':: 119 The following instances (adapted from CHR paper, ex. 18) are sensitive to the order in which rules are applied: 120 {{{ 119 === Loss of confluence === 120 121 The following instances (adapted from CHR paper, ex. 18) are sensitive to the order in which rules are applied: 122 {{{ 121 123 class B a b  a > b 122 124 class C a b c  a > b where f :: a > b > c > Bool … … 124 126 instance B a b => C [a] [b] Bool 125 127 }}} 126 127 128 129 128 Given the constraint ``C [a] [b] Bool, C [a] [c] d``, 129 * if we apply the dependency first, and then reduce using the instances, we obtain ``b = c, B a b, C [a] [b] d``. 130 * if we first reduce using the instances, we obtain ``B a b, C [a] [c] d``. 131 (GHC and Hugs yield the former, because they defer context reduction: see FlexibleContexts). 130 132 131 == Fixes ==133 == Proposed Fixes == 132 134 133 135 The following are alternatives.