1 {-# LANGUAGE AllowAmbiguousTypes #-} -- For grammar
2 {-# LANGUAGE ConstraintKinds #-} -- For Grammar
3 module Symantic.Parser.Grammar
4 ( module Symantic.Parser.Grammar
5 , module Symantic.Parser.Grammar.Combinators
6 , module Symantic.Parser.Grammar.Fixity
7 , module Symantic.Parser.Grammar.Optimize
8 , module Symantic.Parser.Grammar.ObserveSharing
9 , module Symantic.Parser.Grammar.Write
10 , module Symantic.Parser.Grammar.View
14 import Symantic.Parser.Grammar.Combinators
15 import Symantic.Parser.Grammar.View
16 import Symantic.Parser.Grammar.Fixity
17 import Symantic.Parser.Grammar.ObserveSharing
18 import Symantic.Parser.Grammar.Optimize
19 import Symantic.Parser.Grammar.Write
21 import Data.Function ((.))
22 import Data.String (String)
23 import Text.Show (Show(..))
24 import qualified Language.Haskell.TH.Syntax as TH
27 type Grammar tok repr =
31 , Letable TH.Name repr
32 , Letsable TH.Name repr
35 , CombSatisfiable tok repr
40 -- | A usual pipeline to interpret 'Comb'inators:
41 -- 'observeSharing' then 'optimizeGrammar' then a polymorphic @(repr)@.
44 ObserveSharing TH.Name
45 (OptimizeGrammar repr) a ->
47 grammar = optimizeGrammar . observeSharing
49 -- | An usual pipeline to show 'Comb'inators:
50 -- 'observeSharing' then 'optimizeGrammar' then 'viewGrammar' then 'show'.
52 ShowLetName showName TH.Name =>
53 ObserveSharing TH.Name
54 (OptimizeGrammar (ViewGrammar showName)) a ->
56 showGrammar = show . viewGrammar . grammar