Copyright | (c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2020 Douglas Burke |
---|---|
License | GPL V2 |
Maintainer | Douglas Burke |
Stability | experimental |
Portability | H98 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This program is a simple skeleton for constructing Semantic Web [1] inference tools in Haskell, using the RDF graph and several RDF parsers (at present Notation 3 and NTriples).
It might be viewed as a kind of embroyonic CWM [2] in Haskell, except that the intent is that Haskell will be used as a primary language for defining inferences. As such, Swish is an open-ended toolkit for constructing new special-purpose Semantic Web applications rather than a closed, self-contained general-purpose SW application. As such, it is part of another experiment along the lines described in [3].
The script format used by Swish is described in Swish.Script.
Users wishing to process RDF data directly may prefer to look at the following modules; Swish.RDF, Swish.RDF.Parser.Turtle, Swish.RDF.Parser.N3, Swish.RDF.Parser.NTriples, Swish.RDF.Formatter.Turtle, Swish.RDF.Formatter.N3 and Swish.RDF.Formatter.NTriples.
- Semantic web: http://www.w3.org/2001/sw/
- CWM: http://www.w3.org/2000/10/swap/doc/cwm.html
- Motivation: http://www.w3.org/2000/10/swap/doc/Motivation.html
- Notation 3: http://www.w3.org/TeamSubmission/2008/SUBM-n3-20080114/
- Turtle: http://www.w3.org/TR/turtle/
- RDF: http://www.w3.org/RDF/
Notes
I anticipate that this module may be used as a starting point for creating new programs rather then as a complete program in its own right. The functionality built into this code is selected with a view to testing the Haskell modules for handling RDF rather than for performing any particular application processing (though development as a tool with some broader utility is not ruled out).
With the following in ghci:
>>>
:m + Swish
>>>
:set prompt "swish> "
then we can run a Swish script (format described in Swish.Script) by saying:
>>>
runSwish "-s=script.ss"
ExitSuccess
or convert a file from Turtle to NTriples format with:
>>>
runSwish "-ttl -i=foo.ttl -nt -o=foo.nt"
ExitSuccess
You can also use validateCommands
by giving it the individual commands,
such as
>>>
let Right cs = validateCommands ["-ttl", "-i=file1.ttl", "-c=file2.ttl"]
>>>
cs
[SwishAction: -ttl,SwishAction: -i=file1.ttl,SwishAction: -c=file2.ttl]>>>
st <- runSwishActions cs
>>>
st
The graphs do not compare as equal.
Synopsis
- data SwishStatus
- data SwishAction
- runSwish :: String -> IO ExitCode
- runSwishActions :: [SwishAction] -> IO SwishStatus
- displaySwishHelp :: IO ()
- splitArguments :: [String] -> ([String], [String])
- validateCommands :: [String] -> Either (String, SwishStatus) [SwishAction]
Documentation
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 SwishAction Source #
Represent a Swish action. At present there is no way to create these
actions other than validateCommands
.
Instances
Show SwishAction Source # | |
Defined in Swish showsPrec :: Int -> SwishAction -> ShowS # show :: SwishAction -> String # showList :: [SwishAction] -> ShowS # |
runSwish :: String -> IO ExitCode Source #
Parse and run the given string as if given at the command line. The "quiet", "version" and "help" options are ignored.
runSwishActions :: [SwishAction] -> IO SwishStatus Source #
Execute the given set of actions.
displaySwishHelp :: IO () Source #
Write out the help for Swish
splitArguments :: [String] -> ([String], [String]) Source #
Return any arguments that need processing immediately, namely the "help", "quiet" and "version" options.
validateCommands :: [String] -> Either (String, SwishStatus) [SwishAction] Source #
Given a list of command-line arguments create the list of actions to perform or a string and status value indicating an input error.