doc: fix old names
[haskell/symantic-parser.git] / src / Symantic / Parser / Grammar / Optimize.hs
index 9053b4d0f1d8e0093b5670bce958344d2ee9c8c8..cb6ee76524d4e67651eea7105b6bd06923f3de17 100644 (file)
@@ -27,10 +27,10 @@ import qualified Language.Haskell.TH as TH
 
 import Symantic.Parser.Grammar.Combinators
 import Symantic.Parser.Grammar.Production
-import Symantic.Parser.Grammar.ObserveSharing hiding (def)
+import Symantic.Parser.Grammar.ObserveSharing
 import Symantic.Derive
+import qualified Symantic.Class as Prod
 import qualified Symantic.Data as Prod
-import qualified Symantic.Lang as Prod
 
 {-
 import Data.Function (($), flip)
@@ -70,23 +70,23 @@ instance Derivable (KnotComb letName repr) where
 instance LiftDerived (KnotComb letName repr) where
   liftDerived x = KnotComb
     { knotCombOpens = HM.empty
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \_final -> TiedComb
         { combSimpl = x
         }
     }
 instance LiftDerived1 (KnotComb letName repr) where
   liftDerived1 f a = a
-    { knotCombOpen = \finals -> TiedComb
-      { combSimpl = f (combSimpl (knotCombOpen a finals))
+    { knotCombOpen = \final -> TiedComb
+      { combSimpl = f (combSimpl (knotCombOpen a final))
       }
     }
 instance (Eq letName, Hashable letName) => LiftDerived2 (KnotComb letName repr) where
   liftDerived2 f a b = KnotComb
     { knotCombOpens = knotCombOpens a <> knotCombOpens b
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \final -> TiedComb
       { combSimpl = f
-         (combSimpl (knotCombOpen a finals))
-         (combSimpl (knotCombOpen b finals))
+         (combSimpl (knotCombOpen a final))
+         (combSimpl (knotCombOpen b final))
       }
     }
 instance (Eq letName, Hashable letName) => LiftDerived3 (KnotComb letName repr) where
@@ -96,11 +96,11 @@ instance (Eq letName, Hashable letName) => LiftDerived3 (KnotComb letName repr)
       , knotCombOpens b
       , knotCombOpens c
       ]
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \final -> TiedComb
       { combSimpl = f
-         (combSimpl (knotCombOpen a finals))
-         (combSimpl (knotCombOpen b finals))
-         (combSimpl (knotCombOpen c finals))
+         (combSimpl (knotCombOpen a final))
+         (combSimpl (knotCombOpen b final))
+         (combSimpl (knotCombOpen c final))
       }
     }
 instance (Eq letName, Hashable letName) => LiftDerived4 (KnotComb letName repr) where
@@ -111,12 +111,12 @@ instance (Eq letName, Hashable letName) => LiftDerived4 (KnotComb letName repr)
       , knotCombOpens c
       , knotCombOpens d
       ]
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \final -> TiedComb
       { combSimpl = f
-         (combSimpl (knotCombOpen a finals))
-         (combSimpl (knotCombOpen b finals))
-         (combSimpl (knotCombOpen c finals))
-         (combSimpl (knotCombOpen d finals))
+         (combSimpl (knotCombOpen a final))
+         (combSimpl (knotCombOpen b final))
+         (combSimpl (knotCombOpen c final))
+         (combSimpl (knotCombOpen d final))
       }
     }
 
@@ -526,11 +526,11 @@ instance
         $ knotCombOpens a
         : knotCombOpens d
         : ((\(_p, b) -> knotCombOpens b) F.<$> bs)
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \final -> TiedComb
         { combSimpl = conditional
-            (combSimpl (knotCombOpen a finals))
-            ((\(p, b) -> (p, combSimpl (knotCombOpen b finals))) F.<$> bs)
-            (combSimpl (knotCombOpen d finals))
+            (combSimpl (knotCombOpen a final))
+            ((\(p, b) -> (p, combSimpl (knotCombOpen b final))) F.<$> bs)
+            (combSimpl (knotCombOpen d final))
         }
     }
 
@@ -666,7 +666,7 @@ instance -- TODO: optimizations
     }
   getUnscoped r = SimplComb
     { combData = GetUnscoped r
-    , combInline = False -- FIXME: True
+    , combInline = True
     , combRefs = HS.empty
     }
   putUnscoped r x = SimplComb
@@ -715,10 +715,10 @@ instance
           -- since there is only a single 'lets' at the top of the AST,
           -- but well.
           : ((\(SomeLet sub) -> knotCombOpens sub) F.<$> HM.elems defs)
-    , knotCombOpen = \finals -> TiedComb
+    , knotCombOpen = \final -> TiedComb
         { combSimpl =
-          let bodySimpl = combSimpl $ knotCombOpen body finals in
-          let defsSimpl = (\(SomeLet sub) -> SomeLet $ combSimpl $ knotCombOpen sub finals) F.<$> defs in
+          let bodySimpl = combSimpl $ knotCombOpen body final in
+          let defsSimpl = (\(SomeLet sub) -> SomeLet $ combSimpl $ knotCombOpen sub final) F.<$> defs in
           let defsUsed = HS.unions
                 $ combRefs bodySimpl
                 : ((\(SomeLet sub) -> combRefs sub) F.<$> HM.elems defsSimpl) in
@@ -747,12 +747,12 @@ instance
   Referenceable TH.Name (KnotComb TH.Name repr) where
   ref isRec name = KnotComb
     { knotCombOpens = HM.empty
-    , knotCombOpen = \finals ->
+    , knotCombOpen = \final ->
       if isRec
       then TiedComb
         { combSimpl = ref isRec name
         }
-      else case finals HM.! name of
+      else case final HM.! name of
         SomeLet a@TiedComb
           { combSimpl = p@SimplComb{ combInline = True }
           } -> a{combSimpl = unsafeSimplComb p}