1 {-# LANGUAGE ConstraintKinds #-}
2 module Symantic.Parser.Grammar
3 ( module Symantic.Parser.Grammar
4 , module Symantic.Parser.Grammar.Combinators
5 , module Symantic.Parser.Grammar.Optimize
6 , module Symantic.Parser.Grammar.ObserveSharing
7 , module Symantic.Parser.Grammar.Write
8 , module Symantic.Parser.Grammar.Dump
11 import Symantic.Parser.Grammar.Combinators
12 import Symantic.Parser.Grammar.Optimize
13 import Symantic.Parser.Grammar.ObserveSharing
14 import Symantic.Parser.Grammar.Write
15 import Symantic.Parser.Grammar.Dump
16 import Symantic.Univariant.Letable (Letable(..))
18 import Data.Function ((.))
19 import Data.String (String)
20 import Text.Show (Show(..))
21 import qualified Language.Haskell.TH.Syntax as TH
28 , Letable TH.Name repr
35 -- | A usual pipeline to interpret 'Comb'inators:
36 -- 'observeSharing' then 'optimizeComb' then a polymorphic @(repr)@.
37 grammar :: Grammar repr => ObserveSharing TH.Name (OptimizeComb TH.Name repr) a -> repr a
38 grammar = optimizeComb . observeSharing
40 -- | A usual pipeline to show 'Comb'inators:
41 -- 'observeSharing' then 'optimizeComb' then 'dumpComb' then 'show'.
42 showGrammar :: ObserveSharing TH.Name (OptimizeComb TH.Name DumpComb) a -> String
43 showGrammar = show . dumpComb . optimizeComb . observeSharing