import qualified Language.Haskell.TH.Syntax as TH
import qualified Language.Haskell.TH.Show as TH
-import Symantic.Typed.Data
-import Symantic.Typed.Lang
-import Symantic.Typed.Optim
-import Symantic.Typed.Trans
+import Symantic.Data
+import Symantic.Lang
+import Symantic.Derive
type Production = Product
(SomeData Identity)
{-# INLINE runValue #-}
runValue :: Production a -> a
-runValue x = runIdentity (trans x)
+runValue (Pair v _c) = runIdentity (derive v)
{-# INLINE runCode #-}
runCode :: Production a -> TH.CodeQ a
-runCode = trans
+runCode (Pair _v c) = derive c
-- Missing instances in 'Language.Haskell.TH',
-- needed for 'prodCon'.
[| production $(return (TH.ConE n))
(TH.unsafeCodeCoerce (return (TH.ConE $(TH.lift n)))) |]
-instance Trans Production Identity where
- trans (Pair (SomeData v) _c) = trans v
-instance Trans Production TH.CodeQ where
- trans (Pair _v (SomeData c)) = trans c
-
instance Show (SomeData TH.CodeQ a) where
- -- The 'Trans' constraint contained in 'SomeData'
- -- is 'TH.CodeQ', hence 'Symantic.Typed.View' cannot be used here.
+ -- The 'Derivable' constraint contained in 'SomeData'
+ -- is 'TH.CodeQ', hence 'Symantic.View' cannot be used here.
-- Fortunately 'TH.showCode' can be implemented.
- showsPrec p = showString Fun.. TH.showCode p Fun.. trans
+ showsPrec p = showString Fun.. TH.showCode p Fun.. derive
instance (Abstractable f, Abstractable g) => Abstractable (Product f g) where
-- Those 'undefined' are not unreachables by 'f'
instance Equalable Production where
equal = Pair equal equal
-optimizeProduction :: Production a -> Production a
-optimizeProduction (Pair v c) = Pair (normalOrderReduction v) (normalOrderReduction c)
-
-- Identity
instance Anythingable Identity
instance Abstractable Identity where