Copyright | (c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2022 2024 Douglas Burke |
---|---|
License | GPL V2 |
Maintainer | Douglas Burke |
Stability | experimental |
Portability | CPP, DerivingStrategies |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Composed state and IO monad for Swish
Synopsis
- type SwishStateIO a = StateT SwishState IO a
- data SwishState = SwishState {
- format :: SwishFormat
- base :: Maybe QName
- graph :: RDFGraph
- graphs :: NamedGraphMap
- rules :: RDFRuleMap
- rulesets :: RDFRulesetMap
- infomsg :: Maybe String
- errormsg :: Maybe String
- exitcode :: SwishStatus
- data SwishStatus
- data SwishFormat
- type NamedGraphMap = Map ScopedName [RDFGraph]
- emptyState :: SwishState
- setFormat :: SwishFormat -> SwishState -> SwishState
- setBase :: Maybe QName -> SwishState -> SwishState
- setGraph :: RDFGraph -> SwishState -> SwishState
- modGraphs :: (NamedGraphMap -> NamedGraphMap) -> SwishState -> SwishState
- findGraph :: ScopedName -> SwishState -> Maybe [RDFGraph]
- findFormula :: ScopedName -> SwishState -> Maybe RDFFormula
- modRules :: (RDFRuleMap -> RDFRuleMap) -> SwishState -> SwishState
- findRule :: ScopedName -> SwishState -> Maybe RDFRule
- modRulesets :: (RDFRulesetMap -> RDFRulesetMap) -> SwishState -> SwishState
- findRuleset :: ScopedName -> SwishState -> Maybe RDFRuleset
- findOpenVarModify :: ScopedName -> SwishState -> Maybe RDFOpenVarBindingModify
- findDatatype :: ScopedName -> SwishState -> Maybe RDFDatatype
- setInfo :: String -> SwishState -> SwishState
- resetInfo :: SwishState -> SwishState
- setError :: String -> SwishState -> SwishState
- resetError :: SwishState -> SwishState
- setStatus :: SwishStatus -> SwishState -> SwishState
- swishError :: String -> SwishStatus -> SwishStateIO ()
- reportLine :: String -> SwishStateIO ()
Documentation
type SwishStateIO a = StateT SwishState IO a Source #
The state monad used in executing Swish programs.
data SwishState Source #
The State for a Swish "program".
SwishState | |
|
data SwishStatus Source #
Status of the processor
SwishSuccess | successful run |
SwishGraphCompareError | graphs do not compare |
SwishDataInputError | input data problem (ie format/syntax) |
SwishDataAccessError | data access error |
SwishArgumentError | command-line argument error |
SwishExecutionError | error executing a Swish script |
Instances
Enum SwishStatus Source # | |
Defined in Swish.Monad succ :: SwishStatus -> SwishStatus # pred :: SwishStatus -> SwishStatus # toEnum :: Int -> SwishStatus # fromEnum :: SwishStatus -> Int # enumFrom :: SwishStatus -> [SwishStatus] # enumFromThen :: SwishStatus -> SwishStatus -> [SwishStatus] # enumFromTo :: SwishStatus -> SwishStatus -> [SwishStatus] # enumFromThenTo :: SwishStatus -> SwishStatus -> SwishStatus -> [SwishStatus] # | |
Show SwishStatus Source # | |
Defined in Swish.Monad showsPrec :: Int -> SwishStatus -> ShowS # show :: SwishStatus -> String # showList :: [SwishStatus] -> ShowS # | |
Eq SwishStatus Source # | |
Defined in Swish.Monad (==) :: SwishStatus -> SwishStatus -> Bool # (/=) :: SwishStatus -> SwishStatus -> Bool # |
data SwishFormat Source #
The supported input and output formats.
Instances
Show SwishFormat Source # | |
Defined in Swish.Monad showsPrec :: Int -> SwishFormat -> ShowS # show :: SwishFormat -> String # showList :: [SwishFormat] -> ShowS # | |
Eq SwishFormat Source # | |
Defined in Swish.Monad (==) :: SwishFormat -> SwishFormat -> Bool # (/=) :: SwishFormat -> SwishFormat -> Bool # |
type NamedGraphMap = Map ScopedName [RDFGraph] Source #
A LookupMap for the graphs dictionary.
Create and modify the Swish state
emptyState :: SwishState Source #
The default state for Swish: no loaded graphs or rules, and format
set to N3
.
setFormat :: SwishFormat -> SwishState -> SwishState Source #
Change the format.
setBase :: Maybe QName -> SwishState -> SwishState Source #
Change (or remove) the base URI.
setGraph :: RDFGraph -> SwishState -> SwishState Source #
Change the current graph.
modGraphs :: (NamedGraphMap -> NamedGraphMap) -> SwishState -> SwishState Source #
Modify the named graphs.
findGraph :: ScopedName -> SwishState -> Maybe [RDFGraph] Source #
Find a named graph.
findFormula :: ScopedName -> SwishState -> Maybe RDFFormula Source #
Find a formula. The search is first made in the named graphs and then, if not found, the rulesets.
modRules :: (RDFRuleMap -> RDFRuleMap) -> SwishState -> SwishState Source #
Modify the named rules.
findRule :: ScopedName -> SwishState -> Maybe RDFRule Source #
Find a named rule.
modRulesets :: (RDFRulesetMap -> RDFRulesetMap) -> SwishState -> SwishState Source #
Modify the rule sets.
findRuleset :: ScopedName -> SwishState -> Maybe RDFRuleset Source #
Find a rule set.
findOpenVarModify :: ScopedName -> SwishState -> Maybe RDFOpenVarBindingModify Source #
Find a modify rule.
findDatatype :: ScopedName -> SwishState -> Maybe RDFDatatype Source #
Find a data type declaration.
setInfo :: String -> SwishState -> SwishState Source #
Set the information message.
resetInfo :: SwishState -> SwishState Source #
Clear the information message.
setError :: String -> SwishState -> SwishState Source #
Set the error message.
resetError :: SwishState -> SwishState Source #
Clear the error message.
setStatus :: SwishStatus -> SwishState -> SwishState Source #
Set the status.
Error handling
swishError :: String -> SwishStatus -> SwishStateIO () Source #
Report error and set exit status code
reportLine :: String -> SwishStateIO () Source #
Output the text to the standard error stream (a new line is added to the output).