makeBound chokes on types containing tuples of constants
dfoxfranke opened this issue · comments
Daniel Fox Franke commented
The following makeBound
invocation chokes:
{-# LANGUAGE DeriveFunctor, TemplateHaskell #-}
import Bound
import Bound.Name
import Data.Text
type Named b = Name Text b
data Term v
= EVar v
| EApp (Term v) (Term v)
| EAbs (Named ()) (Scope (Named ()) Term v)
deriving (Functor)
makeBound ''Term
boundbug.hs:1:1: error:
Exception when trying to run compile-time code:
This is bad: AppT (ConT Main.Named) (TupleT 0) False
CallStack (from HasCallStack):
error, called at src/Bound/TH.hs:269:35 in bound-2.0.1-13f2bf83f03b2fd0ec7401893dd97861fab71a8bfa55e6a9cf9d765f1a520a4f:Bound.TH
Code: makeBound ''Term
But the following works fine:
data MyUnit = MyUnit deriving (Eq)
data Term v
= EVar v
| EApp (Term v) (Term v)
| EAbs (Named MyUnit) (Scope (Named ()) Term v)
deriving (Functor)
makeBound ''Term
The problem is that makeBound
doesn't recognize ()
as a constant because it parses as an empty tuple, and isKonst
is missing a rule for tuples. The other, remaining occurrence of Named ()
is okay because it gets handled by boundInstance
rather than isKonst
.
Oleg Grenrus commented
I guess it's easy enough to extend the isKonst
, do you want to try?