[Haskell-cafe] RebindableSyntax, ifThenElse, and pattern matching

Chris Smith cdsmith at gmail.com
Sun Feb 7 19:08:33 UTC 2016


In a custom prelude, I have written the following definitions:

data Truth = True | False

ifThenElse :: Truth -> a -> a -> a
ifThenElse True x _ = x
ifThenElse False _ x = x

(==) :: a -> a -> Truth
(==) = ...

I'm replacing Bool with my own Truth type.  Clients will be built with
RebindableSyntax, so that they will use these definitions for desugaring.

However, if I write this:

f :: Text -> Text
f "r" = "rrr"
f other = other

I get a build error indicating that GHC expected the (==) operator to
return a value of type Bool, rather than Truth.

Shouldn't pattern matching desugar to use overloaded ifThenElse in these
situations?  Or is it expected that use of GHC.Types.Bool is hard-coded
even with RebindableSyntax enabled?

Thanks,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160207/066de1f3/attachment.html>


More information about the Haskell-Cafe mailing list