aboutsummaryrefslogtreecommitdiff
path: root/CLPM/Package.dcl
blob: 4a070e2919cffa463822ea84e549097b72b5461b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
definition module CLPM.Package

from StdClass import class Ord
from StdFile import class <<<
from StdOverloaded import class <, class ==, class toString
from StdTuple import instance < (a,b,c) | < a & < b & < c

from Data.Error import :: MaybeError, :: MaybeErrorString
from Data.Maybe import :: Maybe
from Text.JSON import :: JSONNode, generic JSONEncode, generic JSONDecode

from CLPM.Repository import :: Repository, :: RepositoryItem
from CLPM.Util import class Parse

DEFAULT_NAME :== "Unnamed package"
DEFAULT_VERSION :== (0,1,0)
DEFAULT_DESC :== "Empty description"
DEFAULT_AUTHOR :== "Unknown author"
DEFAULT_URL :== "http://clean.cs.ru.nl"
DEFAULT_MAIN :== "main"
DEFAULT_PATHS :== ["."]
DEFAULT_OPTIONS :==
	{ show_result       = True
	, show_constructors = True
	, show_time         = True
	, heap_size         = 2000
	, stack_size        = 500
	, extra_flags       = []
	}

MODULE_DIR :== "clpm_modules"
PACKAGE_FILE :== "clpm.json"

:: StoredPackage

:: Package
	= { name    :: PackageName
	  , version :: Version
	  , desc    :: Description
	  , author  :: Author
	  , url     :: Url
	  , main    :: Maybe Path
	  , depends :: [Dependency]
	  , paths   :: [Path]
	  , options :: Options
	  }

:: Dependency
	= Package PackageName VersionRequirement

:: Options
	= { show_result       :: Bool
	  , show_constructors :: Bool
	  , show_time         :: Bool
	  , heap_size         :: Int
	  , stack_size        :: Int
	  , extra_flags       :: [String]
	  }

:: PackageName :== String
:: Version :== (Int, Int, Int)
:: Description :== String
:: Author :== String
:: Url :== String
:: Path :== String

:: GitTag
	= Commit String
	| Tag String
	| Latest

:: VersionRequirement
	= AtLeast Version
	| AtMost Version
	| Satisfy (Maybe Int, Maybe Int, Maybe Int)
	| Compound VersionRequirement VersionRequirement

derive JSONEncode StoredPackage
derive JSONDecode StoredPackage

instance <<< Package

instance toString Version

instance == Dependency
instance == VersionRequirement
instance == GitTag

instance Parse Dependency
instance Parse VersionRequirement

depName :: Dependency -> PackageName

satisfies :: VersionRequirement Version -> Bool

toPackage :: StoredPackage -> MaybeErrorString Package
toStoredPackage :: Package -> StoredPackage

readPackage :: String *World -> *(MaybeErrorString Package, *World)

resolveDependencies :: Repository Package -> MaybeErrorString [(Dependency, Version)]

getRecursivePaths :: Package *World -> (MaybeErrorString [Path], *World)
optionsToFlags :: Options -> [String]

install :: Dependency Version *World -> *(MaybeErrorString String, *World)