Commit 33e9f5c7 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Remove old functor parser module

parent 7fb7884f
......@@ -37,7 +37,6 @@ library
, Data.OpenUnion
, Text.Parser.Lexer
, Text.Parser.Types
, Text.Parser.Functor
, Parser
, Algorithm
, MA.FunctorExpression.Type
......
......@@ -8,21 +8,11 @@
{-# LANGUAGE StandaloneDeriving #-}
module Data.RefinementInterface where
import Data.Text (Text)
import Data.Yaml as Yaml
import Data.Vector as Vector
import Data.MorphismEncoding
data ArgumentParser h
= NoArguments h
| ArgumentParser (Yaml.Value -> Yaml.Parser h)
data RefinableFunctor = forall h. RefinementInterface h => RefinableFunctor
{ name :: Text
, parseArguments :: ArgumentParser (h ())
}
class ( Show (h ())
, Show (Label h)
, Show (H1 h)
......@@ -42,8 +32,3 @@ class ( Show (h ())
parse :: h () -> Vector Yaml.Value -> Yaml.Parser (Encoding (Label h) (H1 h))
init :: H1 h -> [Label h] -> Weight h
update :: [Label h] -> Weight h -> (Weight h, H3 h, Weight h)
data SomeRefinementInterface where
SomeRefinementInterface :: RefinementInterface h => h () -> SomeRefinementInterface
deriving instance Show SomeRefinementInterface
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Parser.Functor
( FunctorParser(..)
, SomeFunctorParser(..)
, functorsParser
)
where
import Text.Megaparsec
import qualified Text.Megaparsec.Expr as Expr
import Text.Parser.Types
import Text.Parser.Lexer
import Data.RefinementInterface
data FunctorParser a = Prefix (Parser a) | Postfix (Parser a)
deriving (Functor)
data SomeFunctorParser where
SomeFunctorParser :: RefinementInterface h => FunctorParser (h ()) -> SomeFunctorParser
makeOpTable :: [[SomeFunctorParser]] -> [[Expr.Operator Parser [SomeRefinementInterface]]]
makeOpTable = map (map funcToOp)
where
funcToOp :: SomeFunctorParser -> Expr.Operator Parser [SomeRefinementInterface]
funcToOp (SomeFunctorParser funcParser) = case funcParser of
Prefix p -> Expr.Prefix ((:) . SomeRefinementInterface <$> p)
Postfix p -> Expr.Postfix ((:) . SomeRefinementInterface <$> p)
functorsParser :: [[SomeFunctorParser]] -> Parser [SomeRefinementInterface]
functorsParser functors = try spaceConsumer *> Expr.makeExprParser term (makeOpTable functors)
where
term = parens (functorsParser functors) <|> (symbol "X" >> return [])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment