[Haskell-cafe] "SameConstraints?" type constraints

Leza Morais Lutonda leza.ml at fecrd.cujae.edu.cu
Fri Jun 19 05:38:01 UTC 2015

On 06/19/2015 01:23 AM, David Johnson wrote:
> You could constrain d in the type signature of SC.
> {-# LANGUAGE GADTs #-}dataS e whereSC::Show d => d -> e ->S e
> instanceShow e =>Show (S e) whereshow (SC x y) = show x ++ show y

Hi David, thanks for the rapid answer.

But, I also want an instance for Num like:

instance Num e => Show (S e) where
     (SC x1 y1) + (SC x2 y2) = SC (x1+x2) (y1+y2)

And in the future I will want another instance that constraints to the `e` type.
And the client of the library will implement his own instances or functions.
So I think it wont be nice to constraint `Show d` in the type signature of the `SC` constructor.

Leza Morais Lutonda, Lemol-C
Electronic and Telecommunication Engineer
Software Development and Architecture Enthusiast

50 Aniversario de la Cujae. Inaugurada por Fidel el 2 de diciembre de 1964  http://cujae.edu.cu

More information about the Haskell-Cafe mailing list