
No, constraints aren't a part of type e. But you can specify the constraint in SC itself: data SC c e where SC :: c d => d -> e -> S e (or SC :: (c d, c e) => d -> e -> S e, if you like it better). Of course, you would need ConstraintKind for that. Отправлено с iPad
19 июня 2015 г., в 7:16, Leza Morais Lutonda
написал(а): 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
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe