Skip to content

Nested TH not allowed in declarations

I tried to do the following with the singletons and derive libraries:

$(singletons [d|
  data CrudRoute = AddR | EditR | DeleteR | ViewR
    deriving (Eq,Ord,Enum,Bounded,Show)
  data MyRoute = UsersR | ProfileR | RenameR | DogR CrudRoute
    deriving (Eq,Ord,Show)
  $( derive makeEnum ''MyRoute ) 
  |])

GHC fails with the following error message:

Splices within declaration brackets not (yet) handled by Template Haskell

Here is the github issue where this originated: https://github.com/goldfirere/singletons/issues/135#issuecomment-158936027

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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