[Haskell-beginners] Structural restrictions in type constructor
Martin Vlk
martin at vlkk.cz
Mon Jun 22 11:34:40 UTC 2015
But this is checking the values in the implementation, not a type level
build time guarantee, isn't it?
M
Imants Cekusins:
> we could use pattern matched constructor:
>
> module PairsMatched where
>
> data MyP t = MyP (t,t)(t,t) deriving Show
>
>
> myP_ctor:: Eq t => (t,t)->(t,t)->MyP t
> myP_ctor (a1,a2) (a3,a4)
> | a1 == a4 && a2 == a3 = MyP (a1,a2) (a3,a4)
> | otherwise = error "mismatched pairs"
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
More information about the Beginners
mailing list