2 ms·
In Haskell this is caught as a type error. But you can make your own version: class ExtendedBool t where toBool :: t -> Bool instance Extende
by eru 16y ago
In Haskell this is caught as a type error. But you can make your own version:
class ExtendedBool t where
toBool :: t -> Bool
instance ExtendedBool Int where
toBool = (0/=)
instance ExtendedBool [a] where
toBool = not . null
if' v a b =
if (toBool v)
then a
else b
main = if' "String"
(print "True")
(print "False")