Copyright | (C) CSIRO 2017-2019 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- module Data.Validation
- module Language.Python.Validate.Syntax.Error
- data Syntax
- type ValidateSyntax e = ValidateM (NonEmpty e) (ReaderT SyntaxContext (State [String]))
- runValidateSyntax :: ValidateSyntax e a -> Validation (NonEmpty e) a
- validateModuleSyntax :: (AsSyntaxError e a, Member Indentation v) => Module v a -> ValidateSyntax e (Module (Nub (Syntax ': v)) a)
- validateStatementSyntax :: (AsSyntaxError e a, Member Indentation v) => Statement v a -> ValidateSyntax e (Statement (Nub (Syntax ': v)) a)
- validateExprSyntax :: (AsSyntaxError e a, Member Indentation v) => Expr v a -> ValidateSyntax e (Expr (Nub (Syntax ': v)) a)
- data SyntaxContext = SyntaxContext {
- _inLoop :: Bool
- _inFinally :: Bool
- _inFunction :: Maybe FunctionInfo
- _inGenerator :: Bool
- _inClass :: Bool
- _inParens :: Bool
- data FunctionInfo = FunctionInfo {
- _functionParams :: [String]
- _asyncFunction :: Bool
- inLoop :: Lens' SyntaxContext Bool
- inFunction :: Lens' SyntaxContext (Maybe FunctionInfo)
- inGenerator :: Lens' SyntaxContext Bool
- inParens :: Lens' SyntaxContext Bool
- runValidateSyntax' :: SyntaxContext -> [String] -> ValidateSyntax e a -> Validation (NonEmpty e) a
- initialSyntaxContext :: SyntaxContext
- reservedWords :: [String]
- canAssignTo :: Expr v a -> Bool
- deleteBy' :: (a -> b -> Bool) -> a -> [b] -> [b]
- deleteFirstsBy' :: (a -> b -> Bool) -> [a] -> [b] -> [a]
- localNonlocals :: ([String] -> [String]) -> ValidateSyntax e a -> ValidateSyntax e a
- validateArgsSyntax :: (AsSyntaxError e a, Member Indentation v) => CommaSep1' (Arg v a) -> ValidateSyntax e (CommaSep1' (Arg (Nub (Syntax ': v)) a))
- validateBlockSyntax :: (AsSyntaxError e a, Member Indentation v) => Block v a -> ValidateSyntax e (Block (Nub (Syntax ': v)) a)
- validateCompoundStatementSyntax :: forall e v a. (AsSyntaxError e a, Member Indentation v) => CompoundStatement v a -> ValidateSyntax e (CompoundStatement (Nub (Syntax ': v)) a)
- validateComprehensionSyntax :: (AsSyntaxError e a, Member Indentation v) => (ex v a -> ValidateSyntax e (ex (Nub (Syntax ': v)) a)) -> Comprehension ex v a -> ValidateSyntax e (Comprehension ex (Nub (Syntax ': v)) a)
- validateDecoratorSyntax :: (AsSyntaxError e a, Member Indentation v) => Decorator v a -> ValidateSyntax e (Decorator (Nub (Syntax ': v)) a)
- validateDictItemSyntax :: (AsSyntaxError e a, Member Indentation v) => DictItem v a -> ValidateSyntax e (DictItem (Nub (Syntax ': v)) a)
- validateExceptAsSyntax :: (AsSyntaxError e a, Member Indentation v) => ExceptAs v a -> ValidateSyntax e (ExceptAs (Nub (Syntax ': v)) a)
- validateIdentSyntax :: (AsSyntaxError e a, Member Indentation v) => Ident v a -> ValidateSyntax e (Ident (Nub (Syntax ': v)) a)
- validateImportAsSyntax :: (AsSyntaxError e a, Member Indentation v) => (t v a -> ValidateSyntax e (t' (Nub (Syntax ': v)) a)) -> ImportAs t v a -> ValidateSyntax e (ImportAs t' (Nub (Syntax ': v)) a)
- validateImportTargetsSyntax :: (AsSyntaxError e a, Member Indentation v) => ImportTargets v a -> ValidateSyntax e (ImportTargets (Nub (Syntax ': v)) a)
- validateListItemSyntax :: (AsSyntaxError e a, Member Indentation v) => ListItem v a -> ValidateSyntax e (ListItem (Nub (Syntax ': v)) a)
- validateParamsSyntax :: forall e v a. (AsSyntaxError e a, Member Indentation v) => Bool -> CommaSep (Param v a) -> ValidateSyntax e (CommaSep (Param (Nub (Syntax ': v)) a))
- validateSetItemSyntax :: (AsSyntaxError e a, Member Indentation v) => SetItem v a -> ValidateSyntax e (SetItem (Nub (Syntax ': v)) a)
- validateSimpleStatementSyntax :: forall e a v. (AsSyntaxError e a, Member Indentation v) => SimpleStatement v a -> ValidateSyntax e (SimpleStatement (Nub (Syntax ': v)) a)
- validateStringLiteralSyntax :: AsSyntaxError e a => StringLiteral a -> ValidateSyntax e (StringLiteral a)
- validateSubscriptSyntax :: (AsSyntaxError e a, Member Indentation v) => Subscript v a -> ValidateSyntax e (Subscript (Nub (Syntax ': v)) a)
- validateSuiteSyntax :: (AsSyntaxError e a, Member Indentation v) => Suite v a -> ValidateSyntax e (Suite (Nub (Syntax ': v)) a)
- validateTupleItemSyntax :: (AsSyntaxError e a, Member Indentation v) => TupleItem v a -> ValidateSyntax e (TupleItem (Nub (Syntax ': v)) a)
- validateWhitespace :: (AsSyntaxError e a, Foldable f) => a -> f Whitespace -> ValidateSyntax e (f Whitespace)
Documentation
module Data.Validation
Main validation functions
type ValidateSyntax e = ValidateM (NonEmpty e) (ReaderT SyntaxContext (State [String])) Source #
runValidateSyntax :: ValidateSyntax e a -> Validation (NonEmpty e) a Source #
validateModuleSyntax :: (AsSyntaxError e a, Member Indentation v) => Module v a -> ValidateSyntax e (Module (Nub (Syntax ': v)) a) Source #
validateStatementSyntax :: (AsSyntaxError e a, Member Indentation v) => Statement v a -> ValidateSyntax e (Statement (Nub (Syntax ': v)) a) Source #
validateExprSyntax :: (AsSyntaxError e a, Member Indentation v) => Expr v a -> ValidateSyntax e (Expr (Nub (Syntax ': v)) a) Source #
Miscellany
Extra types
data SyntaxContext Source #
SyntaxContext | |
|
data FunctionInfo Source #
runValidateSyntax' :: SyntaxContext -> [String] -> ValidateSyntax e a -> Validation (NonEmpty e) a Source #
Extra functions
reservedWords :: [String] Source #
canAssignTo :: Expr v a -> Bool Source #
deleteFirstsBy' :: (a -> b -> Bool) -> [a] -> [b] -> [a] Source #
localNonlocals :: ([String] -> [String]) -> ValidateSyntax e a -> ValidateSyntax e a Source #
Validation functions
validateArgsSyntax :: (AsSyntaxError e a, Member Indentation v) => CommaSep1' (Arg v a) -> ValidateSyntax e (CommaSep1' (Arg (Nub (Syntax ': v)) a)) Source #
validateBlockSyntax :: (AsSyntaxError e a, Member Indentation v) => Block v a -> ValidateSyntax e (Block (Nub (Syntax ': v)) a) Source #
validateCompoundStatementSyntax :: forall e v a. (AsSyntaxError e a, Member Indentation v) => CompoundStatement v a -> ValidateSyntax e (CompoundStatement (Nub (Syntax ': v)) a) Source #
validateComprehensionSyntax :: (AsSyntaxError e a, Member Indentation v) => (ex v a -> ValidateSyntax e (ex (Nub (Syntax ': v)) a)) -> Comprehension ex v a -> ValidateSyntax e (Comprehension ex (Nub (Syntax ': v)) a) Source #
validateDecoratorSyntax :: (AsSyntaxError e a, Member Indentation v) => Decorator v a -> ValidateSyntax e (Decorator (Nub (Syntax ': v)) a) Source #
validateDictItemSyntax :: (AsSyntaxError e a, Member Indentation v) => DictItem v a -> ValidateSyntax e (DictItem (Nub (Syntax ': v)) a) Source #
validateExceptAsSyntax :: (AsSyntaxError e a, Member Indentation v) => ExceptAs v a -> ValidateSyntax e (ExceptAs (Nub (Syntax ': v)) a) Source #
validateIdentSyntax :: (AsSyntaxError e a, Member Indentation v) => Ident v a -> ValidateSyntax e (Ident (Nub (Syntax ': v)) a) Source #
validateImportAsSyntax :: (AsSyntaxError e a, Member Indentation v) => (t v a -> ValidateSyntax e (t' (Nub (Syntax ': v)) a)) -> ImportAs t v a -> ValidateSyntax e (ImportAs t' (Nub (Syntax ': v)) a) Source #
validateImportTargetsSyntax :: (AsSyntaxError e a, Member Indentation v) => ImportTargets v a -> ValidateSyntax e (ImportTargets (Nub (Syntax ': v)) a) Source #
validateListItemSyntax :: (AsSyntaxError e a, Member Indentation v) => ListItem v a -> ValidateSyntax e (ListItem (Nub (Syntax ': v)) a) Source #
:: (AsSyntaxError e a, Member Indentation v) | |
=> Bool | These are the parameters to a lambda |
-> CommaSep (Param v a) | |
-> ValidateSyntax e (CommaSep (Param (Nub (Syntax ': v)) a)) |
validateSetItemSyntax :: (AsSyntaxError e a, Member Indentation v) => SetItem v a -> ValidateSyntax e (SetItem (Nub (Syntax ': v)) a) Source #
validateSimpleStatementSyntax :: forall e a v. (AsSyntaxError e a, Member Indentation v) => SimpleStatement v a -> ValidateSyntax e (SimpleStatement (Nub (Syntax ': v)) a) Source #
validateStringLiteralSyntax :: AsSyntaxError e a => StringLiteral a -> ValidateSyntax e (StringLiteral a) Source #
validateSubscriptSyntax :: (AsSyntaxError e a, Member Indentation v) => Subscript v a -> ValidateSyntax e (Subscript (Nub (Syntax ': v)) a) Source #
validateSuiteSyntax :: (AsSyntaxError e a, Member Indentation v) => Suite v a -> ValidateSyntax e (Suite (Nub (Syntax ': v)) a) Source #
validateTupleItemSyntax :: (AsSyntaxError e a, Member Indentation v) => TupleItem v a -> ValidateSyntax e (TupleItem (Nub (Syntax ': v)) a) Source #
validateWhitespace :: (AsSyntaxError e a, Foldable f) => a -> f Whitespace -> ValidateSyntax e (f Whitespace) Source #