{-# LANGUAGE FlexibleInstances #-}
module Parser.TypeInstance (
) where
import Control.Applicative ((<|>))
import Base.GeneralType
import Base.Mergeable (mergeAll,mergeAny)
import Base.Positional
import Parser.Common
import Parser.TextParser hiding ((<|>),single)
import Types.TypeInstance
instance ParseFromSource GeneralInstance where
sourceParser :: TextParser GeneralInstance
sourceParser = TextParser GeneralInstance
single TextParser GeneralInstance
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser GeneralInstance
allT TextParser GeneralInstance
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser GeneralInstance
anyT TextParser GeneralInstance
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser GeneralInstance
intersectOrUnion where
allT :: TextParser GeneralInstance
allT = String -> TextParser GeneralInstance -> TextParser GeneralInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"all" (TextParser GeneralInstance -> TextParser GeneralInstance)
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwAll
GeneralInstance -> TextParser GeneralInstance
forall (m :: * -> *) a. Monad m => a -> m a
return GeneralInstance
forall a. Bounded a => a
minBound
anyT :: TextParser GeneralInstance
anyT = String -> TextParser GeneralInstance -> TextParser GeneralInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"any" (TextParser GeneralInstance -> TextParser GeneralInstance)
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwAny
GeneralInstance -> TextParser GeneralInstance
forall (m :: * -> *) a. Monad m => a -> m a
return GeneralInstance
forall a. Bounded a => a
maxBound
intersectOrUnion :: TextParser GeneralInstance
intersectOrUnion = String -> TextParser GeneralInstance -> TextParser GeneralInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"union or intersection" (TextParser GeneralInstance -> TextParser GeneralInstance)
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall a b. (a -> b) -> a -> b
$ do
TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"["
GeneralInstance
t1 <- String -> TextParser GeneralInstance -> TextParser GeneralInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"type" (TextParser GeneralInstance -> TextParser GeneralInstance)
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall a b. (a -> b) -> a -> b
$ TextParser GeneralInstance
forall a. ParseFromSource a => TextParser a
sourceParser
GeneralInstance
t <- GeneralInstance -> TextParser GeneralInstance
forall b.
(ParseFromSource b, Mergeable b) =>
b -> ParsecT CompilerMessage String Identity b
intersect GeneralInstance
t1 TextParser GeneralInstance
-> TextParser GeneralInstance -> TextParser GeneralInstance
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> GeneralInstance -> TextParser GeneralInstance
forall b.
(ParseFromSource b, Mergeable b) =>
b -> ParsecT CompilerMessage String Identity b
union GeneralInstance
t1
TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"]"
GeneralInstance -> TextParser GeneralInstance
forall (m :: * -> *) a. Monad m => a -> m a
return GeneralInstance
t
intersect :: b -> ParsecT CompilerMessage String Identity b
intersect b
t1 = do
[b]
ts <- ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity [b]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
some (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (String -> TextParser ()
string_ String
"&") TextParser ()
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall a. String -> TextParser a -> TextParser a
labeled String
"type" ParsecT CompilerMessage String Identity b
forall a. ParseFromSource a => TextParser a
sourceParser)
b -> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> ParsecT CompilerMessage String Identity b)
-> b -> ParsecT CompilerMessage String Identity b
forall a b. (a -> b) -> a -> b
$ [b] -> b
forall a (f :: * -> *). (Mergeable a, Foldable f) => f a -> a
mergeAll (b
t1b -> [b] -> [b]
forall a. a -> [a] -> [a]
:[b]
ts)
union :: b -> ParsecT CompilerMessage String Identity b
union b
t1 = do
[b]
ts <- ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity [b]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
some (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (String -> TextParser ()
string_ String
"|") TextParser ()
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall a. String -> TextParser a -> TextParser a
labeled String
"type" ParsecT CompilerMessage String Identity b
forall a. ParseFromSource a => TextParser a
sourceParser)
b -> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a. Monad m => a -> m a
return (b -> ParsecT CompilerMessage String Identity b)
-> b -> ParsecT CompilerMessage String Identity b
forall a b. (a -> b) -> a -> b
$ [b] -> b
forall a (f :: * -> *). (Mergeable a, Foldable f) => f a -> a
mergeAny (b
t1b -> [b] -> [b]
forall a. a -> [a] -> [a]
:[b]
ts)
single :: TextParser GeneralInstance
single = (TypeInstanceOrParam -> GeneralInstance)
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> TextParser GeneralInstance
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TypeInstanceOrParam -> GeneralInstance
forall a. (Eq a, Ord a) => a -> GeneralType a
singleType ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a. ParseFromSource a => TextParser a
sourceParser
instance ParseFromSource ValueType where
sourceParser :: TextParser ValueType
sourceParser = do
StorageType
r <- TextParser StorageType
getWeak TextParser StorageType
-> TextParser StorageType -> TextParser StorageType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser StorageType
getOptional TextParser StorageType
-> TextParser StorageType -> TextParser StorageType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser StorageType
getRequired
GeneralInstance
t <- TextParser GeneralInstance
forall a. ParseFromSource a => TextParser a
sourceParser
ValueType -> TextParser ValueType
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueType -> TextParser ValueType)
-> ValueType -> TextParser ValueType
forall a b. (a -> b) -> a -> b
$ StorageType -> GeneralInstance -> ValueType
ValueType StorageType
r GeneralInstance
t
where
getWeak :: TextParser StorageType
getWeak = String -> TextParser StorageType -> TextParser StorageType
forall a. String -> TextParser a -> TextParser a
labeled String
"weak" (TextParser StorageType -> TextParser StorageType)
-> TextParser StorageType -> TextParser StorageType
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwWeak
StorageType -> TextParser StorageType
forall (m :: * -> *) a. Monad m => a -> m a
return StorageType
WeakValue
getOptional :: TextParser StorageType
getOptional = String -> TextParser StorageType -> TextParser StorageType
forall a. String -> TextParser a -> TextParser a
labeled String
"optional" (TextParser StorageType -> TextParser StorageType)
-> TextParser StorageType -> TextParser StorageType
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwOptional
StorageType -> TextParser StorageType
forall (m :: * -> *) a. Monad m => a -> m a
return StorageType
OptionalValue
getRequired :: TextParser StorageType
getRequired = StorageType -> TextParser StorageType
forall (m :: * -> *) a. Monad m => a -> m a
return StorageType
RequiredValue
instance ParseFromSource CategoryName where
sourceParser :: TextParser CategoryName
sourceParser = String -> TextParser CategoryName -> TextParser CategoryName
forall a. String -> TextParser a -> TextParser a
labeled String
"type name" (TextParser CategoryName -> TextParser CategoryName)
-> TextParser CategoryName -> TextParser CategoryName
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
noKeywords
Char
b <- ParsecT CompilerMessage String Identity Char
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
upperChar
String
e <- TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ ParsecT CompilerMessage String Identity Char -> TextParser String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ParsecT CompilerMessage String Identity Char
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
alphaNumChar
CategoryName -> TextParser CategoryName
forall (m :: * -> *) a. Monad m => a -> m a
return (CategoryName -> TextParser CategoryName)
-> CategoryName -> TextParser CategoryName
forall a b. (a -> b) -> a -> b
$ String -> CategoryName
box (Char
bChar -> String -> String
forall a. a -> [a] -> [a]
:String
e)
where
box :: String -> CategoryName
box String
n
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"Bool" = CategoryName
BuiltinBool
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"Char" = CategoryName
BuiltinChar
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"Int" = CategoryName
BuiltinInt
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"Float" = CategoryName
BuiltinFloat
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"String" = CategoryName
BuiltinString
| String
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"Formatted" = CategoryName
BuiltinFormatted
| Bool
otherwise = String -> CategoryName
CategoryName String
n
instance ParseFromSource ParamName where
sourceParser :: TextParser ParamName
sourceParser = String -> TextParser ParamName -> TextParser ParamName
forall a. String -> TextParser a -> TextParser a
labeled String
"param name" (TextParser ParamName -> TextParser ParamName)
-> TextParser ParamName -> TextParser ParamName
forall a b. (a -> b) -> a -> b
$ TextParser ParamName
self TextParser ParamName
-> TextParser ParamName -> TextParser ParamName
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser ParamName
custom where
self :: TextParser ParamName
self = do
TextParser ()
paramSelf
ParamName -> TextParser ParamName
forall (m :: * -> *) a. Monad m => a -> m a
return ParamName
ParamSelf
custom :: TextParser ParamName
custom = do
TextParser ()
noKeywords
Char -> TextParser ()
char_ Char
'#'
Char
b <- ParsecT CompilerMessage String Identity Char
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
lowerChar
String
e <- TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ ParsecT CompilerMessage String Identity Char -> TextParser String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ParsecT CompilerMessage String Identity Char
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
alphaNumChar
ParamName -> TextParser ParamName
forall (m :: * -> *) a. Monad m => a -> m a
return (ParamName -> TextParser ParamName)
-> ParamName -> TextParser ParamName
forall a b. (a -> b) -> a -> b
$ String -> ParamName
ParamName (Char
'#'Char -> String -> String
forall a. a -> [a] -> [a]
:Char
bChar -> String -> String
forall a. a -> [a] -> [a]
:String
e)
instance ParseFromSource TypeInstance where
sourceParser :: TextParser TypeInstance
sourceParser = String -> TextParser TypeInstance -> TextParser TypeInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"type instance" (TextParser TypeInstance -> TextParser TypeInstance)
-> TextParser TypeInstance -> TextParser TypeInstance
forall a b. (a -> b) -> a -> b
$ do
CategoryName
n <- TextParser CategoryName
forall a. ParseFromSource a => TextParser a
sourceParser
[GeneralInstance]
as <- String
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall a. String -> TextParser a -> TextParser a
labeled String
"type args" (TextParser [GeneralInstance] -> TextParser [GeneralInstance])
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall a b. (a -> b) -> a -> b
$ TextParser [GeneralInstance]
args TextParser [GeneralInstance]
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> [GeneralInstance] -> TextParser [GeneralInstance]
forall (m :: * -> *) a. Monad m => a -> m a
return []
TypeInstance -> TextParser TypeInstance
forall (m :: * -> *) a. Monad m => a -> m a
return (TypeInstance -> TextParser TypeInstance)
-> TypeInstance -> TextParser TypeInstance
forall a b. (a -> b) -> a -> b
$ CategoryName -> InstanceParams -> TypeInstance
TypeInstance CategoryName
n ([GeneralInstance] -> InstanceParams
forall a. [a] -> Positional a
Positional [GeneralInstance]
as)
where
args :: TextParser [GeneralInstance]
args = TextParser String
-> TextParser String
-> TextParser [GeneralInstance]
-> TextParser [GeneralInstance]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
"<")
(TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
">")
(TextParser GeneralInstance
-> TextParser String -> TextParser [GeneralInstance]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser GeneralInstance
forall a. ParseFromSource a => TextParser a
sourceParser (TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
","))
instance ParseFromSource DefinesInstance where
sourceParser :: TextParser DefinesInstance
sourceParser = String -> TextParser DefinesInstance -> TextParser DefinesInstance
forall a. String -> TextParser a -> TextParser a
labeled String
"type instance" (TextParser DefinesInstance -> TextParser DefinesInstance)
-> TextParser DefinesInstance -> TextParser DefinesInstance
forall a b. (a -> b) -> a -> b
$ do
CategoryName
n <- TextParser CategoryName
forall a. ParseFromSource a => TextParser a
sourceParser
[GeneralInstance]
as <- String
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall a. String -> TextParser a -> TextParser a
labeled String
"type args" (TextParser [GeneralInstance] -> TextParser [GeneralInstance])
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall a b. (a -> b) -> a -> b
$ TextParser [GeneralInstance]
args TextParser [GeneralInstance]
-> TextParser [GeneralInstance] -> TextParser [GeneralInstance]
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> [GeneralInstance] -> TextParser [GeneralInstance]
forall (m :: * -> *) a. Monad m => a -> m a
return []
DefinesInstance -> TextParser DefinesInstance
forall (m :: * -> *) a. Monad m => a -> m a
return (DefinesInstance -> TextParser DefinesInstance)
-> DefinesInstance -> TextParser DefinesInstance
forall a b. (a -> b) -> a -> b
$ CategoryName -> InstanceParams -> DefinesInstance
DefinesInstance CategoryName
n ([GeneralInstance] -> InstanceParams
forall a. [a] -> Positional a
Positional [GeneralInstance]
as)
where
args :: TextParser [GeneralInstance]
args = TextParser String
-> TextParser String
-> TextParser [GeneralInstance]
-> TextParser [GeneralInstance]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
"<")
(TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
">")
(TextParser GeneralInstance
-> TextParser String -> TextParser [GeneralInstance]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser GeneralInstance
forall a. ParseFromSource a => TextParser a
sourceParser (TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
","))
instance ParseFromSource TypeInstanceOrParam where
sourceParser :: ParsecT CompilerMessage String Identity TypeInstanceOrParam
sourceParser = ParsecT CompilerMessage String Identity TypeInstanceOrParam
inst ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT CompilerMessage String Identity TypeInstanceOrParam
param where
param :: ParsecT CompilerMessage String Identity TypeInstanceOrParam
param = String
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a. String -> TextParser a -> TextParser a
labeled String
"param" (ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam)
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a b. (a -> b) -> a -> b
$ (ParamName -> TypeInstanceOrParam)
-> TextParser ParamName
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Bool -> ParamName -> TypeInstanceOrParam
JustParamName Bool
False) TextParser ParamName
forall a. ParseFromSource a => TextParser a
sourceParser
inst :: ParsecT CompilerMessage String Identity TypeInstanceOrParam
inst = String
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a. String -> TextParser a -> TextParser a
labeled String
"type instance" (ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam)
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a b. (a -> b) -> a -> b
$ (TypeInstance -> TypeInstanceOrParam)
-> TextParser TypeInstance
-> ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TypeInstance -> TypeInstanceOrParam
JustTypeInstance TextParser TypeInstance
forall a. ParseFromSource a => TextParser a
sourceParser
instance ParseFromSource TypeFilter where
sourceParser :: TextParser TypeFilter
sourceParser = TextParser TypeFilter
requires TextParser TypeFilter
-> TextParser TypeFilter -> TextParser TypeFilter
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser TypeFilter
allows TextParser TypeFilter
-> TextParser TypeFilter -> TextParser TypeFilter
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser TypeFilter
defines where
requires :: TextParser TypeFilter
requires = String -> TextParser TypeFilter -> TextParser TypeFilter
forall a. String -> TextParser a -> TextParser a
labeled String
"requires filter" (TextParser TypeFilter -> TextParser TypeFilter)
-> TextParser TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwRequires
TypeInstanceOrParam
t <- ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a. ParseFromSource a => TextParser a
sourceParser
TypeFilter -> TextParser TypeFilter
forall (m :: * -> *) a. Monad m => a -> m a
return (TypeFilter -> TextParser TypeFilter)
-> TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ FilterDirection -> GeneralInstance -> TypeFilter
TypeFilter FilterDirection
FilterRequires (GeneralInstance -> TypeFilter) -> GeneralInstance -> TypeFilter
forall a b. (a -> b) -> a -> b
$ TypeInstanceOrParam -> GeneralInstance
forall a. (Eq a, Ord a) => a -> GeneralType a
singleType TypeInstanceOrParam
t
allows :: TextParser TypeFilter
allows = String -> TextParser TypeFilter -> TextParser TypeFilter
forall a. String -> TextParser a -> TextParser a
labeled String
"allows filter" (TextParser TypeFilter -> TextParser TypeFilter)
-> TextParser TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwAllows
TypeInstanceOrParam
t <- ParsecT CompilerMessage String Identity TypeInstanceOrParam
forall a. ParseFromSource a => TextParser a
sourceParser
TypeFilter -> TextParser TypeFilter
forall (m :: * -> *) a. Monad m => a -> m a
return (TypeFilter -> TextParser TypeFilter)
-> TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ FilterDirection -> GeneralInstance -> TypeFilter
TypeFilter FilterDirection
FilterAllows (GeneralInstance -> TypeFilter) -> GeneralInstance -> TypeFilter
forall a b. (a -> b) -> a -> b
$ TypeInstanceOrParam -> GeneralInstance
forall a. (Eq a, Ord a) => a -> GeneralType a
singleType TypeInstanceOrParam
t
defines :: TextParser TypeFilter
defines = String -> TextParser TypeFilter -> TextParser TypeFilter
forall a. String -> TextParser a -> TextParser a
labeled String
"defines filter" (TextParser TypeFilter -> TextParser TypeFilter)
-> TextParser TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
kwDefines
DefinesInstance
t <- TextParser DefinesInstance
forall a. ParseFromSource a => TextParser a
sourceParser
TypeFilter -> TextParser TypeFilter
forall (m :: * -> *) a. Monad m => a -> m a
return (TypeFilter -> TextParser TypeFilter)
-> TypeFilter -> TextParser TypeFilter
forall a b. (a -> b) -> a -> b
$ DefinesInstance -> TypeFilter
DefinesFilter DefinesInstance
t