[GHC] #10405: Pattern synonym fails with (Exp Bool) but works with (t ~ Bool => Exp t)

GHC ghc-devs at haskell.org
Mon May 11 20:17:53 UTC 2015


#10405: Pattern synonym fails with (Exp Bool) but works with (t ~ Bool => Exp t)
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                   Owner:
            Type:  bug               |                  Status:  closed
        Priority:  normal            |               Milestone:
       Component:  Compiler (Type    |                 Version:  7.10.1-rc1
  checker)                           |                Keywords:
      Resolution:  invalid           |            Architecture:  x86
Operating System:  Linux             |               Test Case:
 Type of failure:  GHC rejects       |                Blocking:
  valid program                      |  Differential Revisions:
      Blocked By:                    |
 Related Tickets:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 Egg on my face, I should have realised that. Thanks for the response.

 For anyone in a similar situation and for future evaluation of #9953 I
 have the expression:

 {{{#!haskell
 data Tag a where
   TInt  :: Tag Int
   TBool :: Tag Bool
   …

 data Exp a where
   Fn₁ :: String -> Tag a          -> (a -> b)      -> (Exp a -> Exp b)
   Fn₂ :: String -> Tag a -> Tag b -> (a -> b -> c) -> (Exp a -> Exp b ->
 Exp c)
   …
 }}}

 To be able to match against expressions of type `Exp a` I needed to add an
 additional tag for the return type:

 {{{#!haskell
 data Exp a where
   Fn₁ :: String -> Tag a -> Tag b          -> (a -> b)      -> (Exp a ->
 Exp b)
   Fn₂ :: String -> Tag a -> Tag b -> Tag c -> (a -> b -> c) -> (Exp a ->
 Exp b -> Exp c)
   …
 }}}

 {{{#!haskell
 pattern Leq :: (a ~ Int, b ~ Int, c ~ Bool) => Exp a -> Exp b -> Exp c
 pattern Leq a b ← Fn₂ "leq" TInt TInt TBool _    a b where
         Leq a b = Fn₂ "leq" TInt TInt TBool (<=) a b
 }}}

 is the final version.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10405#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list