[Haskell-cafe] "SameConstraints?" type constraints

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


Hi All,

I have the following data type:

  data S e where

      SC :: d -> e -> S e

And I want to declare a Show instance for it in the following way:

  instance Show e => Show (S e) where

     show (SC x y) = show x ++ show y

But, of course it don't typechecks because: could not deduce `Show d` arising from a use of `show`.
Is there a way to constraint the `d` type in the `SC` constructor definition to have the same constraints of the `e` type? Something like:

   SC :: SameConstraints d e => d -> e -> S e ???


Thanks!


-- 
Leza Morais Lutonda, Lemol-C
http://lemol.github.io



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