1 {-# LANGUAGE AllowAmbiguousTypes #-} -- For grammar
2 {-# LANGUAGE ConstraintKinds #-} -- For Grammarable
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.Production
10 , module Symantic.Parser.Grammar.Write
11 , module Symantic.Parser.Grammar.View
15 import Symantic.Parser.Grammar.Combinators
16 import Symantic.Parser.Grammar.Fixity
17 import Symantic.Parser.Grammar.ObserveSharing
18 import Symantic.Parser.Grammar.Optimize
19 import Symantic.Parser.Grammar.Production
20 import Symantic.Parser.Grammar.View
21 import Symantic.Parser.Grammar.Write
23 import Control.DeepSeq (NFData)
26 import Data.Function ((.))
27 import Data.String (String)
28 import Data.Typeable (Typeable)
29 import Text.Show (Show(..))
30 import qualified Language.Haskell.TH.Syntax as TH
32 -- * Class 'Grammarable'
33 type Grammarable tok repr =
37 , Letable TH.Name repr
38 , Letsable TH.Name repr
41 , CombSatisfiable tok repr
51 -- | A usual pipeline to interpret 'Comb'inators:
52 -- 'observeSharing' then 'optimizeGrammar' then a polymorphic @(repr)@.
54 Grammarable tok repr =>
55 ObserveSharing TH.Name
56 (OptimizeGrammar repr) a ->
58 grammar = optimizeGrammar . observeSharing
60 -- | An usual pipeline to show 'Comb'inators:
61 -- 'observeSharing' then 'optimizeGrammar' then 'viewGrammar' then 'show'.
62 showGrammar :: forall showName a tok repr.
63 repr ~ ObserveSharing TH.Name (OptimizeGrammar (ViewGrammar showName)) =>
64 ShowLetName showName TH.Name =>
65 Grammarable tok repr =>
67 showGrammar = show . viewGrammar . grammar @tok