
On 13 September 2011 23:04, Grigory Sarnitskiy
Hello! I'm trying to have a class for booleans called Boolean (the methods are not complete):
class MyEq a where (===) :: (Boolean b) => a -> a -> b
This means that === potentially returns _any_ instance of Boolean. Let's say for example that I define "data MyBool = T | F" and make it an instance of MyEq and Boolean. That means that T === F must be able to return either a Bool, MyBool or any other instance of Boolean that the _caller_ chooses. If this is what you want, then I suggest that you do something like: class (MyEq a) => Boolean a where (/\) :: a -> a -> a fromBool :: Bool -> a Then the instance becomes: instance MyEq Bool where x === y = fromBool $ x==y instance Boolean Bool where (/\) = (&&) fromBool = id -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com