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

Chris Smith cdsmith at gmail.com
Mon Feb 8 06:16:48 UTC 2016


Thanks!  Yeah, I just wondered if this was known, or if there's an easy way
around it that I was missing.

For my specific case, I can do just as well by defining a type synonym, and
then post-processing the error messages from GHC.  That's all stuff I
already do, so there's no need to do any work on my account. :)

On Sun, Feb 7, 2016 at 7:06 PM, Richard Eisenberg <eir at cis.upenn.edu> wrote:

> If you have a use-case that requires an expansion of RebindableSyntax,
> please post a feature request. There is a very limited number of
> person-hours devoted to improving GHC, so we need concrete direction from
> users.
>
> That said, RebindableSyntax has gotten quite a face-lift for 8.0, mostly
> internally. But it means that some types are more flexible than they were.
> However, neither problem in this thread is addressed by the changes.
>
> But to the email below: I'm not sure how we would support anything but
> Bool. According to the Report,
>
> > f "r" = "rrr"
>
> becomes
>
> > f x | x == "r" = "rrr"
>
> Because the result of == is used as a guard, it would have to be a Bool.
> I'd be all for a new -XOverloadedBooleans, but that's still separate from
> RebindableSyntax.
>
> The enumFromTo bit would be easy to fix, though. If you want it for
> practical purposes (that is, not just because its omission is aesthetically
> suboptimal -- which it is), please post a feature request.
>
> Richard
>
> On Feb 7, 2016, at 3:00 PM, Adam Bergmark <adam at bergmark.nl> wrote:
>
> 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.
>
> - Adam
>
>
>
> 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?
>>
>> Thanks,
>> Chris
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160207/a7fb77f0/attachment.html>


More information about the Haskell-Cafe mailing list