1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE NoMonomorphismRestriction #-}
3 module Symantic.Parser.Grammar
4 ( module Symantic.Parser.Grammar
5 , module Symantic.Parser.Grammar.Combinators
6 , module Symantic.Parser.Grammar.Optimize
7 , module Symantic.Parser.Grammar.ObserveSharing
8 , module Symantic.Parser.Grammar.Write
9 , 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)
21 import Text.Show (Show(..))
22 import qualified Data.Functor as Functor
23 import qualified Language.Haskell.TH.Syntax as TH
30 , Letable TH.Name repr
37 -- | A usual pipeline to show 'Comb'inators: 'observeSharing' then 'optimizeComb' then 'dumpComb' then 'show'.
38 -- Note that the 'IO' is required to 'observeSharing' which is required to avoid an infinite recursion when generating.
39 grammar = (optimizeComb Functor.<$>) . observeSharing
41 -- | A usual pipeline to show 'Comb'inators: 'observeSharing' then 'optimizeComb' then 'dumpComb' then 'show'.
42 -- Note that the 'IO' is required to 'observeSharing' which is required to avoid an infinite recursion when the grammar is recursive.
43 showGrammar :: ObserveSharing TH.Name (OptimizeComb TH.Name DumpComb) a -> IO String
44 showGrammar = (show . dumpComb . optimizeComb Functor.<$>) . observeSharing