Constructor as outermost match in RULE under GHC 8.2.2 & 8.4.3

Conal Elliott conal at conal.net
Fri Aug 3 01:25:05 UTC 2018


GHC 8.2.2 and 8.4.3 dislike the following rules:

``` haskell
{-# RULES

"pair fst snd" forall p. (,) (exl p) (exr p) = p

"swap" forall p. (,) (exr p) (exl p) = swap p

 #-}
```

Error messages:

``` haskell
/Users/conal/Haskell/concat/plugin/src/ConCat/Rebox.hs:485:1: warning:
    A constructor, (,), appears as outermost match in RULE lhs.
    This rule will be ignored.
    |
485 | "pair fst snd" forall p. (,) (exl p) (exr p) = p
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Users/conal/Haskell/concat/plugin/src/ConCat/Rebox.hs:489:1: warning:
    A constructor, (,), appears as outermost match in RULE lhs.
    This rule will be ignored.
    |
489 | "swap" forall p. (,) (exr p) (exl p) = swap p
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

GHC 8.0.2 didn't complain about these rules, though I'm unsure whether they
worked as desired.

Why disallow such rules (with constructors at the head)?

-- Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20180802/219983e0/attachment.html>


More information about the Glasgow-haskell-users mailing list