Specialize a function on types of arguments?

18 Nov
2018
18 Nov
'18
4:01 a.m.
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. Best!
2422
Age (days ago)
2422
Last active (days ago)
0 comments
1 participants
participants (1)
-
ducis