rename {Label => LetName}
authorJulien Moutinho <julm+symantic-parser@sourcephile.fr>
Wed, 30 Dec 2020 00:13:33 +0000 (01:13 +0100)
committerJulien Moutinho <julm+symantic-parser@sourcephile.fr>
Wed, 30 Dec 2020 00:13:33 +0000 (01:13 +0100)
src/Symantic/Parser/Automaton/Eval.hs
src/Symantic/Parser/Automaton/Instructions.hs

index 60ba70cf62b2e627ef2322fdb0a9395ca2f2ee55..ac595af9d2872519b2cc80c66fbaa8fe2a5a98a0 100644 (file)
@@ -270,20 +270,20 @@ instance Inputable Eval where
   pushInput k = Eval $ \inh ->
     unEval k inh{valueStack = ValueStackCons (input inh) (valueStack inh)}
 instance Routinable Eval where
-  call (Label n) k = Eval $ \inh ->
+  call (LetName n) k = Eval $ \inh ->
     callWithContinuation
       {-sub-}(Code (TH.unsafeTExpCoerce (return (TH.VarE n))))
       {-ok-}(suspend k inh)
       (input inh)
       {-ko-}(failStack inh)
-  jump (Label n) = Eval $ \inh ->
+  jump (LetName n) = Eval $ \inh ->
     callWithContinuation
       {-sub-}(Code (TH.unsafeTExpCoerce (return (TH.VarE n))))
       {-ok-}(retCode inh)
       (input inh)
       {-ko-}(failStack inh)
   ret = Eval $ \inh -> unEval (resume (retCode inh)) inh
-  subroutine (Label n) sub k = Eval $ \inh -> Code $ TH.unsafeTExpCoerce $ do
+  subroutine (LetName n) sub k = Eval $ \inh -> Code $ TH.unsafeTExpCoerce $ do
     val <- TH.unTypeQ $ TH.examineCode $ [|| -- buildRec in Parsley
       \(!ok) (!inp) ko ->
         $$(unEval sub inh
index 4535c38ed8196df74756a888430d168a45f47a8e..a39760980d1ba2b30949b3d564847d774dd151f9 100644 (file)
@@ -1,5 +1,5 @@
 {-# LANGUAGE ConstraintKinds #-} -- For Executable
-{-# LANGUAGE DerivingStrategies #-} -- For Show (Label a)
+{-# LANGUAGE DerivingStrategies #-} -- For Show (LetName a)
 {-# LANGUAGE PatternSynonyms #-} -- For Fmap, App, …
 {-# LANGUAGE UndecidableInstances #-} -- For Cursorable (Cursor inp)
 module Symantic.Parser.Automaton.Instructions where
@@ -82,21 +82,21 @@ data Instr input valueStack (failStack::Peano) returnValue where
     [Instr inp vs es ret] ->
     Instr inp vs es ret ->
     Instr inp (v ': vs) es ret
-  -- | @('Subroutine' n v k)@ binds the 'Label' @(n)@ to the 'Instr'uction's @(v)@,
+  -- | @('Subroutine' n v k)@ binds the 'LetName' @(n)@ to the 'Instr'uction's @(v)@,
   -- 'Call's @(n)@ and
   -- continues with the next 'Instr'uction @(k)@.
   Subroutine ::
-    Label v -> Instr inp '[] ('Succ 'Zero) v ->
+    LetName v -> Instr inp '[] ('Succ 'Zero) v ->
     Instr inp vs ('Succ es) ret ->
     Instr inp vs ('Succ es) ret
   -- | @('Jump' n k)@ pass the control-flow to the 'Subroutine' named @(n)@.
   Jump ::
-    Label ret ->
+    LetName ret ->
     Instr inp '[] ('Succ es) ret
   -- | @('Call' n k)@ pass the control-flow to the 'Subroutine' named @(n)@,
   -- and when it 'Ret'urns, continues with the next 'Instr'uction @(k)@.
   Call ::
-    Label v ->
+    LetName v ->
     Instr inp (v ': vs) ('Succ es) ret ->
     Instr inp vs ('Succ es) ret
   -- | @('Ret')@ returns the value stored in a singleton 'valueStack'.
@@ -125,8 +125,8 @@ instance Trans InstrPure TH.CodeQ where
     InstrPureHaskell x -> trans x
     InstrPureSameOffset -> sameOffset
 
--- ** Type 'Label'
-newtype Label a = Label { unLabel :: TH.Name }
+-- ** Type 'LetName'
+newtype LetName a = LetName { unLetName :: TH.Name }
   deriving (Eq)
   deriving newtype Show
 
@@ -191,16 +191,16 @@ class Inputable (repr :: Type -> [Type] -> Peano -> Type -> Type) where
 -- ** Class 'Routinable'
 class Routinable (repr :: Type -> [Type] -> Peano -> Type -> Type) where
   subroutine ::
-    Label v -> repr inp '[] ('Succ 'Zero) v ->
+    LetName v -> repr inp '[] ('Succ 'Zero) v ->
     repr inp vs ('Succ es) ret ->
     repr inp vs ('Succ es) ret
   call ::
-    Label v -> repr inp (v ': vs) ('Succ es) ret ->
+    LetName v -> repr inp (v ': vs) ('Succ es) ret ->
     repr inp vs ('Succ es) ret
   ret ::
     repr inp '[ret] es ret
   jump ::
-    Label ret ->
+    LetName ret ->
     repr inp '[] ('Succ es) ret
 
 -- ** Class 'Readable'
@@ -350,10 +350,10 @@ instance
       (LoadInput (Push (InstrPureHaskell H.unit) k))
 instance Letable TH.Name (Automaton inp) where
   def n v = Automaton $ \k ->
-    Subroutine (Label n) (unAutomaton v Ret) (Call (Label n) k)
+    Subroutine (LetName n) (unAutomaton v Ret) (Call (LetName n) k)
   ref _isRec n = Automaton $ \case
-    Ret -> Jump (Label n)
-    k -> Call (Label n) k
+    Ret -> Jump (LetName n)
+    k -> Call (LetName n) k
 instance Cursorable (Cursor inp) => Foldable (Automaton inp) where
   {-
   chainPre op p = go <*> p