unison-syntax-0.0.0
Safe HaskellNone
LanguageHaskell2010

Unison.Syntax.Parser

Synopsis

Documentation

class Annotated a where Source #

Methods

ann :: a -> Ann Source #

Instances

Instances details
Annotated Void Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: Void -> Ann Source #

Annotated Ann Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: Ann -> Ann Source #

Annotated a => Annotated (NonEmpty a) Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: NonEmpty a -> Ann Source #

Annotated a => Annotated (Pattern a) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

ann :: Pattern a -> Ann Source #

Annotated (Token a) Source # 
Instance details

Defined in Unison.Syntax.Lexer.Token

Methods

ann :: Token a -> Ann Source #

Annotated (Pattern v) Source # 
Instance details

Defined in Unison.Syntax.Pattern

Methods

ann :: Pattern v -> Ann Source #

Annotated a => Annotated (Maybe a) Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: Maybe a -> Ann Source #

Annotated a => Annotated [a] Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: [a] -> Ann Source #

Annotated a => Annotated (Cofree f a) Source # 
Instance details

Defined in Unison.Parser.Ann

Methods

ann :: Cofree f a -> Ann Source #

(Annotated a, Annotated b) => Annotated (MatchCase a b) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

ann :: MatchCase a b -> Ann Source #

Annotated a => Annotated (Term f v a) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

ann :: Term f v a -> Ann Source #

data Error v Source #

Constructors

SignatureNeedsAccompanyingBody (Token v) 
DisallowedAbsoluteName (Token Name) 
EmptyBlock (Token String) 
UnknownTerm (Token (HashQualified Name)) (Set Referent) 
UnknownType (Token (HashQualified Name)) (Set Reference) 
UnknownId (Token (HashQualified Name)) (Set Referent) (Set Reference) 
ExpectedBlockOpen String (Token Lexeme) 
EmptyWatch Ann 
UseInvalidPrefixSuffix (Either (Token Name) (Token Name)) (Maybe [Token Name]) 
UseEmpty (Token String) 
DidntExpectExpression (Token Lexeme) (Maybe (Token Lexeme)) 
TypeDeclarationErrors [Error v Ann] 
MissingTypeModifier (Token String) (Token v)

MissingTypeModifier (type|ability) name

TypeNotAllowed (Token (HashQualified Name))

A type was found in a position that requires a term

ResolutionFailures [ResolutionFailure Ann] 
DuplicateTypeNames [(v, [Ann])] 
DuplicateTermNames [(v, [Ann])] 
PatternArityMismatch Int Int Ann

PatternArityMismatch expectedArity actualArity location

FloatPattern Ann 
DuplicateBinders Ann Ann v 
PatternInFunctionDeclaration v Ann

Pattern found in function declaration head (e.g. `f [] = ...`) Carries the function name and the location of the pattern token.

DuplicateRecordField Ann Ann Text

The same field name appeared twice in one record type, literal, or pattern. Args are the first occurrence, the second, and the name.

Instances

Instances details
Show v => Show (Error v) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

showsPrec :: Int -> Error v -> ShowS #

show :: Error v -> String #

showList :: [Error v] -> ShowS #

Eq v => Eq (Error v) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

(==) :: Error v -> Error v -> Bool #

(/=) :: Error v -> Error v -> Bool #

Ord v => Ord (Error v) Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

compare :: Error v -> Error v -> Ordering #

(<) :: Error v -> Error v -> Bool #

(<=) :: Error v -> Error v -> Bool #

(>) :: Error v -> Error v -> Bool #

(>=) :: Error v -> Error v -> Bool #

max :: Error v -> Error v -> Error v #

min :: Error v -> Error v -> Error v #

newtype Input Source #

Constructors

Input 

Fields

Instances

Instances details
Show Input Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

showsPrec :: Int -> Input -> ShowS #

show :: Input -> String #

showList :: [Input] -> ShowS #

Eq Input Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

(==) :: Input -> Input -> Bool #

(/=) :: Input -> Input -> Bool #

Ord Input Source # 
Instance details

Defined in Unison.Syntax.Parser

Methods

compare :: Input -> Input -> Ordering #

(<) :: Input -> Input -> Bool #

(<=) :: Input -> Input -> Bool #

(>) :: Input -> Input -> Bool #

(>=) :: Input -> Input -> Bool #

max :: Input -> Input -> Input #

min :: Input -> Input -> Input #

Stream Input Source # 
Instance details

Defined in Unison.Syntax.Parser

Associated Types

type Token Input 
Instance details

Defined in Unison.Syntax.Parser

type Tokens Input 
Instance details

Defined in Unison.Syntax.Parser

VisualStream Input Source # 
Instance details

Defined in Unison.Syntax.Parser

type Token Input Source # 
Instance details

Defined in Unison.Syntax.Parser

type Tokens Input Source # 
Instance details

Defined in Unison.Syntax.Parser

type P v (m :: Type -> Type) = ParsecT (Error v) Input (ReaderT (ParsingEnv m) m) Source #

data ParsingEnv (m :: Type -> Type) Source #

Constructors

ParsingEnv 

Fields

newtype UniqueName Source #

Constructors

UniqueName (Pos -> Int -> Maybe Text) 

anyToken :: forall v (m :: Type -> Type). Ord v => P v m (Token Lexeme) Source #

blank :: forall v (m :: Type -> Type). Ord v => P v m (Token NameSegment) Source #

Parse a placeholder or typed hole

bytesToken :: forall v (m :: Type -> Type). Ord v => P v m (Token Bytes) Source #

chainl1 :: forall v (m :: Type -> Type) a. Ord v => P v m a -> P v m (a -> a -> a) -> P v m a Source #

Parse p 1+ times, combining with op

chainr1 :: forall v (m :: Type -> Type) a. Ord v => P v m a -> P v m (a -> a -> a) -> P v m a Source #

chainl1Accum :: forall u s (m :: Type -> Type) a. (Stream u, Ord s) => ParsecT s u m a -> ParsecT s u m (a -> a -> a) -> ParsecT s u m (a, [a -> a]) Source #

character :: forall v (m :: Type -> Type). Ord v => P v m (Token Char) Source #

closeBlock :: forall v (m :: Type -> Type). Ord v => P v m (Token ()) Source #

Consume the end of a block

optionalCloseBlock :: forall v (m :: Type -> Type). Ord v => P v m (Token ()) Source #

With layout, blocks might “close” without an explicit outdent (e.g., not even a newline at the end of a Transclude). This allows those blocks to be closed by EOF.

failCommitted :: forall v (m :: Type -> Type) x. Ord v => Error v -> P v m x Source #

failureIf :: forall v (m :: Type -> Type) b a. Ord v => P v m (P v m b) -> P v m a -> P v m b Source #

If p would succeed, this fails uncommitted. Otherwise, failIfOk used to produce the output

hqInfixId :: forall v (m :: Type -> Type). Ord v => P v m (Token (HashQualified Name)) Source #

hqPrefixId :: forall v (m :: Type -> Type). Ord v => P v m (Token (HashQualified Name)) Source #

importRelativeSymbolyId :: forall v (m :: Type -> Type). Ord v => P v m (Token Name) Source #

The + in: use Foo.bar + as a relative Name

importRelativeWordyId :: forall v (m :: Type -> Type). Ord v => P v m (Token Name) Source #

Parse a wordyId as a relative Name, rejecting any hash

importSymbolyId :: forall v (m :: Type -> Type). Ord v => P v m (Token Name) Source #

The + in: use Foo.bar + as a Name

importWordyId :: forall v (m :: Type -> Type). Ord v => P v m (Token Name) Source #

Parse a wordyId as a Name, rejecting any hash

label :: forall v a (m :: Type -> Type). (Ord v, Show a) => String -> P v m a -> P v m a Source #

matchToken :: forall v (m :: Type -> Type). Ord v => Lexeme -> P v m (Token Lexeme) Source #

Match a particular lexeme exactly, and consume it.

mkAnn :: (Annotated a, Annotated b) => a -> b -> Ann Source #

numeric :: forall v (m :: Type -> Type). Ord v => P v m (Token String) Source #

openBlock :: forall v (m :: Type -> Type). Ord v => P v m (Token String) Source #

Consume a block opening and return the string that opens the block.

openBlockWith :: forall v (m :: Type -> Type). Ord v => String -> P v m (Token ()) Source #

peekAny :: forall v (m :: Type -> Type). Ord v => P v m (Token Lexeme) Source #

positionalVar :: (Annotated a, Var v) => a -> v -> v Source #

Gives this var an id based on its position - a useful trick to obtain a variable whose id won't match any other id in the file `positionalVar a Var.missingResult`

prefixDefinitionName :: forall v (m :: Type -> Type). Var v => P v m (Token v) Source #

Parse a prefix identifier e.g. Foo or (+), discarding any hash

prefixTermName :: forall v (m :: Type -> Type). Var v => P v m (Token v) Source #

Parse a prefix identifier e.g. Foo or (+), rejecting any hash This is useful for term declarations, where type signatures and term names should not have hashes.

queryToken :: forall v a (m :: Type -> Type). Ord v => (Lexeme -> Maybe a) -> P v m (Token a) Source #

Virtual pattern match on a lexeme.

reserved :: forall v (m :: Type -> Type). Ord v => String -> P v m (Token String) Source #

Parse a reserved word

resolveUniqueTypeGuid :: forall (m :: Type -> Type) v. (Monad m, Var v) => v -> P v m Modifier Source #

root :: forall v (m :: Type -> Type) a. Ord v => P v m a -> P v m a Source #

rootFile :: forall v (m :: Type -> Type) a. Ord v => P v m a -> P v m a Source #

run' :: (Monad m, Ord v) => P v m a -> String -> String -> ParsingEnv m -> m (Either (Err v) a) Source #

run :: (Monad m, Ord v) => P v m a -> String -> ParsingEnv m -> m (Either (Err v) a) Source #

semi :: forall v (m :: Type -> Type). Ord v => P v m (Token ()) Source #

Consume a virtual semicolon

seq :: forall v a (m :: Type -> Type). Ord v => (Ann -> [a] -> a) -> P v m a -> P v m a Source #

seq' :: forall v a b (m :: Type -> Type). Ord v => String -> (Ann -> [a] -> b) -> P v m a -> P v m b Source #

sepBy :: forall v (m :: Type -> Type) a b. Ord v => P v m a -> P v m b -> P v m [b] Source #

sepBy1 :: forall v (m :: Type -> Type) a b. Ord v => P v m a -> P v m b -> P v m [b] Source #

string :: forall v (m :: Type -> Type). Ord v => P v m (Token Text) Source #

symbolyDefinitionName :: forall v (m :: Type -> Type). Var v => P v m (Token v) Source #

Parse a symboly ID like >>= or &&, discarding any hash

tok :: (Ann -> a -> b) -> Token a -> b Source #

tupleOrParenthesized :: forall v (m :: Type -> Type) a. Ord v => P v m a -> (Ann -> a) -> (a -> a -> a) -> P v m (Ann, a) Source #

Parses a tuple of as, or a single parenthesized a

returns the result of combining elements with pair, alongside the annotation containing the full parenthesized expression.

uniqueName :: forall (m :: Type -> Type) v. (Monad m, Var v) => Int -> P v m Text Source #

wordyDefinitionName :: forall v (m :: Type -> Type). Var v => P v m (Token v) Source #

Parse a wordy identifier e.g. Foo, discarding any hash

wordyPatternName :: forall v (m :: Type -> Type). Var v => P v m (Token v) Source #

recordFieldName :: forall v (m :: Type -> Type). Var v => P v m (Token Text) Source #

recordSetFieldName :: forall v (m :: Type -> Type). Var v => P v m (Token Text) Source #

The foo in foo.set, for the record-update operator r@foo.set v. A field name is a single segment, so foo.set lexes as one qualified name and is pulled apart here.

checkForDuplicateRecordFields :: forall v (m :: Type -> Type). Ord v => [Token Text] -> P v m () Source #

Reject a record type, literal, or pattern that names the same field twice. Without this the field map is built with fromList, which silently keeps the last binding.

Orphan instances

Annotated a => Annotated (Pattern a) Source # 
Instance details

Methods

ann :: Pattern a -> Ann Source #

(Annotated a, Annotated b) => Annotated (MatchCase a b) Source # 
Instance details

Methods

ann :: MatchCase a b -> Ann Source #

Annotated a => Annotated (Term f v a) Source # 
Instance details

Methods

ann :: Term f v a -> Ann Source #