Skip to content

Template Haskell ignores bad type family definitions

This garbage is accepted:

data Nat = Zero | Succ Nat

$( [d| type family a + b where
         Maybe Zero b = b
         Succ a + b = Succ (a + b) |] )

Note the Maybe photo-bombing in the first equation. The problem is that TH uses the symbol declared in the family head for all the equations, ignoring what's actually there. This is sad.

Trac metadata
Trac field Value
Version 8.4.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information