]> Git — Sourcephile - haskell/symantic-parser.git/blob - src/Symantic/Parser/Grammar.hs
Remove dependency upon symantic-base
[haskell/symantic-parser.git] / src / Symantic / Parser / Grammar.hs
1 {-# LANGUAGE ConstraintKinds #-}
2 module Symantic.Parser.Grammar
3 ( module Symantic.Parser.Grammar
4 , module Symantic.Parser.Grammar.Combinators
5 , module Symantic.Parser.Grammar.Fixity
6 , module Symantic.Parser.Grammar.Optimize
7 , module Symantic.Parser.Grammar.ObserveSharing
8 , module Symantic.Parser.Grammar.Write
9 , module Symantic.Parser.Grammar.Dump
10 , Letable(..)
11 ) where
12 import Symantic.Parser.Grammar.Combinators
13 import Symantic.Parser.Grammar.Dump
14 import Symantic.Parser.Grammar.Fixity
15 import Symantic.Parser.Grammar.ObserveSharing
16 import Symantic.Parser.Grammar.Optimize
17 import Symantic.Parser.Grammar.Write
18 import Symantic.Univariant.Letable (Letable(..))
19
20 import Data.Function ((.))
21 import Data.String (String)
22 import Text.Show (Show(..))
23 import qualified Language.Haskell.TH.Syntax as TH
24
25 -- Class 'Grammar'
26 type Grammar repr =
27 ( Applicable repr
28 , Alternable repr
29 , Charable repr
30 , Letable TH.Name repr
31 , Selectable repr
32 , Matchable repr
33 , Foldable repr
34 , Lookable repr
35 )
36
37 -- | A usual pipeline to interpret 'Comb'inators:
38 -- 'observeSharing' then 'optimizeComb' then a polymorphic @(repr)@.
39 grammar :: Grammar repr => ObserveSharing TH.Name (OptimizeComb TH.Name repr) a -> repr a
40 grammar = optimizeComb . observeSharing
41
42 -- | A usual pipeline to show 'Comb'inators:
43 -- 'observeSharing' then 'optimizeComb' then 'dumpComb' then 'show'.
44 showGrammar :: ObserveSharing TH.Name (OptimizeComb TH.Name DumpComb) a -> String
45 showGrammar = show . dumpComb . optimizeComb . observeSharing