Core.dcl 1.58 KB
Newer Older
1 2 3 4
definition module iTasks.SDS.Sources.Core
/*
* This module provides the builtin shared sources
*/
5
import iTasks.SDS.Definition
6
from System.FilePath import :: FilePath
7
from Data.Error import :: MaybeError, :: MaybeErrorString
Bas Lijnse's avatar
Bas Lijnse committed
8
from Data.Maybe import :: Maybe
9
from Text.GenJSON import generic JSONEncode, generic JSONDecode, :: JSONNode 
10 11

// constant share from which you always read the same value
12
constShare :: !a -> SDSSource p a ()
13 14

// null share to which you can write anything
15
nullShare :: SDSSource p () a
16

Bas Lijnse's avatar
Bas Lijnse committed
17
// Useful placeholder when you need a share don't intent to use it
18
unitShare :: SimpleSDSSource ()
19 20

// Random source
21
randomInt :: SDSSource () Int ()
22

Steffen Michels's avatar
Steffen Michels committed
23
// Random string (the parameters determines its length)
24
randomString :: SDSSource Int String ()
Steffen Michels's avatar
Steffen Michels committed
25

Bas Lijnse's avatar
Bas Lijnse committed
26
// world function share
27
worldShare :: (p *World -> *(MaybeErrorString r,*World)) (p w *World -> *(MaybeErrorString (),*World)) (p Timespec p -> Bool) -> SDSSource p r w
Bas Lijnse's avatar
Bas Lijnse committed
28

29 30 31
// memory share (essentially a global variable)
memoryShare :: SDSSource String (Maybe a) (Maybe a) | TC a

Bas Lijnse's avatar
Bas Lijnse committed
32 33
// Share that maps to the plain contents of a file on disk
// When the file does not exist on reading it returns nothing. By writing Nothing you can remove the file
34
fileShare :: SDSSource FilePath (Maybe String) (Maybe String)
Bas Lijnse's avatar
Bas Lijnse committed
35 36

// Share that maps to a file encoded as JSON 
37
jsonFileShare :: SDSSource FilePath (Maybe a) (Maybe a) | JSONEncode{|*|}, JSONDecode{|*|} a
Bas Lijnse's avatar
Bas Lijnse committed
38 39

// Share that maps to a file that holds a serialized graph representation of the value
40
graphFileShare :: SDSSource FilePath (Maybe a) (Maybe a)
41

Bas Lijnse's avatar
Bas Lijnse committed
42
// Directory
43
directoryListing :: SDSSource FilePath [String] ()