[Haskell-cafe] Specialize a function on types of arguments?

ducis ducis_cn at 126.com
Sun Nov 18 04:01:25 UTC 2018

Hi, everyone,

Is it possible to make combine the following "f" and "g" into one function?
f:: a -> b -> b 
f x y = y       
g:: a -> a -> a 
g x y = x       

Or similarly, "eq1" and "eq2" into one function?
eq1 :: (Eq a)=>a->a->Bool     
eq1 = (==)                    
eq2 :: (Eq a,Eq b)=>a->b->Bool
eq2 _ _ = False               

Looks like it would require some typeclasses, but at least in the first case, "a" and "b" should be any types.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20181118/b642c82a/attachment.html>

More information about the Haskell-Cafe mailing list