{-# LANGUAGE ConstraintKinds #-} module Symantic.Parser.Grammar ( module Symantic.Parser.Grammar , module Symantic.Parser.Grammar.Combinators , module Symantic.Parser.Grammar.Optimize , module Symantic.Parser.Grammar.ObserveSharing , module Symantic.Parser.Grammar.Write , module Symantic.Parser.Grammar.Dump , Letable(..) ) where import Symantic.Parser.Grammar.Combinators import Symantic.Parser.Grammar.Optimize import Symantic.Parser.Grammar.ObserveSharing import Symantic.Parser.Grammar.Write import Symantic.Parser.Grammar.Dump import Symantic.Univariant.Letable (Letable(..)) import Data.Function ((.)) import Data.String (String) import Text.Show (Show(..)) import qualified Language.Haskell.TH.Syntax as TH -- Class 'Grammar' type Grammar repr = ( Applicable repr , Alternable repr , Charable repr , Letable TH.Name repr , Selectable repr , Matchable repr , Foldable repr , Lookable repr ) -- | A usual pipeline to interpret 'Comb'inators: -- 'observeSharing' then 'optimizeComb' then a polymorphic @(repr)@. grammar :: Grammar repr => ObserveSharing TH.Name (OptimizeComb TH.Name repr) a -> repr a grammar = optimizeComb . observeSharing -- | A usual pipeline to show 'Comb'inators: -- 'observeSharing' then 'optimizeComb' then 'dumpComb' then 'show'. showGrammar :: ObserveSharing TH.Name (OptimizeComb TH.Name DumpComb) a -> String showGrammar = show . dumpComb . optimizeComb . observeSharing