Re: [GHC] #8021: Multiple constraint classes - the alternative to superclass

#8021: Multiple constraint classes - the alternative to superclass -------------------------------------+------------------------------------ Reporter: wvv | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by wvv): (I) We don't change the type system. (II) We have some problems with the type inference. Haskell have 2 solution if it has an ambiguity: 1) The error. You must add type signature Functions {{{ foo :: Monoid [a] -> [a] -> [a] -> [a] bar :: (Arrow a, ArrowPlus a, ArrowZero a) => Monoid a => a b c -> a b c -> a b c }}} 2) Default meanings. For example, use class in constraint with minimum dependences. (III) A lot of work for the type checker. Let we have 2 classes: {{{ class C1 => C a0 a1 .. an where data ... type ... f1 :: b1f1 -> b2f2 -> .. -> bn'f1 f2 :: b1f2 -> b2f2 -> .. -> bn''f2 .. fu :: b1fu -> b2fu -> .. -> bn'''fu class C2 => C d0 d1 .. dm where data ... type ... g1 :: b1g1 -> b2g2 -> .. -> bm'g1 g2 :: b1g2 -> b2g2 -> .. -> bm''g2 .. gu' :: b1gu' -> b2gu' -> .. -> bm'''gu' }}} Lows: 1) C1 =/= C2 -- constraint must be different 2) n == m -- number of parameters must be the same 3) u == u' -- number of functions must be the same 4) forall i . s(fi) == s(gi) -- names of functions must be the same 5) forall i. n'{i} == m'{i} -- number of arguments for each functions must be the same 6) forall i j. (bifj :: *) & (bigj :: *) | (bifj :: k) & (bigj :: k) -- corresponding arguments must have the same kind That's all! - forall i. ai :: kia , di :: kid, kia =?= kib - class parameters could have different kinds - datas and types of C1=>C and C2=>C could be different (by number, kind and name) Uses in signature: {{{ foo :: C1 => C a => ... bar :: C2 => C b => ... baz :: C d => .... <<=|=>> baz :: () => C d => ... }}} We use classes like instances of meta-classes -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8021#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC