bump version
[haskell/symantic-parser.git] / src / Symantic / Parser / Machine / Optimize.hs
index 3413b1623c4b14cea6b53eec6f3a02c0c28b1516..f2dec46b887f64e73de499c35ae9c931bda719f8 100644 (file)
@@ -20,15 +20,14 @@ import qualified Language.Haskell.TH as TH
 import Symantic.Parser.Grammar
 import Symantic.Parser.Machine.Input
 import Symantic.Parser.Machine.Instructions
-import Symantic.Univariant.Trans
+import Symantic.Typed.Trans
 
 -- * Data family 'Instr'
 -- | 'Instr'uctions of the 'Machine'.
 -- This is an extensible data-type.
 data family Instr
   (instr :: ReprInstr -> Constraint)
-  (repr :: ReprInstr)
-  :: ReprInstr
+  :: ReprInstr -> ReprInstr
 
 -- | Convenient utility to pattern-match a 'SomeInstr'.
 pattern Instr :: Typeable comb =>
@@ -74,14 +73,14 @@ unSomeInstr (SomeInstr (i::Instr i repr inp vs a)) =
 -- InstrValuable
 data instance Instr InstrValuable repr inp vs a where
   PushValue ::
-    TermInstr v ->
+    Splice v ->
     SomeInstr repr inp (v ': vs) a ->
     Instr InstrValuable repr inp vs a
   PopValue ::
     SomeInstr repr inp vs a ->
     Instr InstrValuable repr inp (v ': vs) a
   Lift2Value ::
-    TermInstr (x -> y -> z) ->
+    Splice (x -> y -> z) ->
     SomeInstr repr inp (z : vs) a ->
     Instr InstrValuable repr inp (y : x : vs) a
   SwapValue ::
@@ -94,6 +93,7 @@ instance InstrValuable repr => Trans (Instr InstrValuable repr inp vs) (repr inp
     Lift2Value f k -> lift2Value f (trans k)
     SwapValue k -> swapValue (trans k)
 instance InstrValuable repr => InstrValuable (SomeInstr repr) where
+  -- 'PopValue' after a 'PushValue' is a no-op.
   pushValue _v (Instr (PopValue i)) = i
   pushValue v i = SomeInstr (PushValue v i)
   popValue = SomeInstr . PopValue
@@ -136,7 +136,7 @@ data instance Instr InstrBranchable repr inp vs a where
     SomeInstr repr inp (y ': vs) a ->
     Instr InstrBranchable repr inp (Either x y ': vs) a
   ChoicesBranch ::
-    [TermInstr (v -> Bool)] ->
+    [Splice (v -> Bool)] ->
     [SomeInstr repr inp vs a] ->
     SomeInstr repr inp vs a ->
     Instr InstrBranchable repr inp (v ': vs) a
@@ -213,7 +213,7 @@ instance InstrInputable repr => InstrInputable (SomeInstr repr) where
 data instance Instr (InstrReadable tok) repr inp vs a where
   Read ::
     Set SomeFailure ->
-    TermInstr (InputToken inp -> Bool) ->
+    Splice (InputToken inp -> Bool) ->
     SomeInstr repr inp (InputToken inp ': vs) a ->
     Instr (InstrReadable tok) repr inp vs a
 instance