News for hackers. Stuff that matters.
Re:The Zen of Python by Example by eru on Friday February 11, 2011 @06:40AM (#2205970)
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")

There are no comments on this comment yet.