License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Some convenient functions for putting together the whole Swarm language processing pipeline: parsing, type checking, capability checking, and elaboration. If you want to simply turn some raw text representing a Swarm program into something useful, this is probably the module you want.
Synopsis
- data ProcessedTerm = ProcessedTerm TModule Requirements ReqCtx
- processTerm :: Text -> Either Text (Maybe ProcessedTerm)
- processParsedTerm :: Syntax -> Either ContextualTypeErr ProcessedTerm
- processTerm' :: TCtx -> ReqCtx -> Text -> Either Text (Maybe ProcessedTerm)
- processParsedTerm' :: TCtx -> ReqCtx -> Syntax -> Either ContextualTypeErr ProcessedTerm
- processTermEither :: Text -> Either Text ProcessedTerm
Documentation
data ProcessedTerm Source #
A record containing the results of the language processing
pipeline. Put a Term
in, and get one of these out. A
ProcessedTerm
contains:
- The elaborated + type-annotated term, plus the types of any
embedded definitions (
TModule
) - The
Requirements
of the term - The requirements context for any definitions embedded in the
term (
ReqCtx
)
Instances
processTerm :: Text -> Either Text (Maybe ProcessedTerm) Source #
Given a Text
value representing a Swarm program,
- Parse it (see Swarm.Language.Parse)
- Typecheck it (see Swarm.Language.Typecheck)
- Elaborate it (see Swarm.Language.Elaborate)
- Check what capabilities it requires (see Swarm.Language.Capability)
Return either the end result (or Nothing
if the input was only
whitespace) or a pretty-printed error message.
processParsedTerm :: Syntax -> Either ContextualTypeErr ProcessedTerm Source #
Like processTerm
, but use a term that has already been parsed.
processTerm' :: TCtx -> ReqCtx -> Text -> Either Text (Maybe ProcessedTerm) Source #
Like processTerm
, but use explicit starting contexts.
processParsedTerm' :: TCtx -> ReqCtx -> Syntax -> Either ContextualTypeErr ProcessedTerm Source #
Like processTerm'
, but use a term that has already been parsed.