[Haskell-cafe] RebindableSyntax, ifThenElse, and pattern matching
adam at bergmark.nl
Sun Feb 7 20:00:28 UTC 2016
There are a number of things one might expect RebindableSyntax to support,
but it doesn't. Another examples is that `[1..2]' uses
`GHC.Enum.enumFromTo' instead of the `enumFromTo' in scope.
My guess is that RebindableSyntax isn't on the priority list.
On Sun, Feb 7, 2016 at 8:08 PM, Chris Smith <cdsmith at gmail.com> wrote:
> 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?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe