Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-22 Thread TP
adam vogt wrote: > I think context and constraint mean the same thing. The haskell report > uses the word context for > for the whole list > and constraint for one part of that list (Eq a). With the extension > -XConstraintKinds both of those are ca

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-22 Thread adam vogt
On Sun, Sep 22, 2013 at 11:07 AM, TP wrote: > My misunderstanding came from a confusion between a "context" and a > "constraint". The context is what is before the =>, and the constraint is > what is after, i.e. the main part of the instance declaration. Hi TP, I think context and constraint mea

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-22 Thread TP
TP wrote: > But I have still a question: is the behavior of GHC correct in the example > of my initial post? See here: http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/type-class-extensions.html#instance-overlap """ When matching, GHC takes no account of the context of the instance decla

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
adam vogt wrote: > You can add another instance to cover the case that everything is zero. > Then you don't need the :<. Also it's convenient to arrange for the > a,b,c to be the argument to Tensor, as given below: > > class Multiplication a b c | a b -> c where > (*) :: Tensor a -> Tensor b

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread adam vogt
Hi TP, You can add another instance to cover the case that everything is zero. Then you don't need the :<. Also it's convenient to arrange for the a,b,c to be the argument to Tensor, as given below: class Multiplication a b c | a b -> c where (*) :: Tensor a -> Tensor b -> Tensor c instance

[Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
Hi everybody, I encouter some problem in my code in the following simple example: two instances overlap for the multiplication sign `*`. The `OverlappingInstances` extension is of no help because it seems GHC does not look at the instance context to decide which instance is the most specific.