-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRattus.cabal
216 lines (164 loc) · 6.92 KB
/
Rattus.cabal
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
cabal-version: 1.18
name: Rattus
version: 0.5.1.1
category: FRP
synopsis: A modal FRP language
description:
This library implements the Rattus programming language as
an embedded DSL. To this end the library provides a GHC
plugin that performs the additional checks that are
necessary for Rattus. What follows is a brief
introduction to the language and its usage. A more
detailed introduction can be found in this
<src/docs/paper.pdf paper>.
.
Rattus is a functional reactive programming (FRP) language
that uses modal types to ensure operational properties
that are crucial for reactive programs: productivity (in
each computation step, the program makes progress),
causality (output depends only on current and earlier
input), and no implicit space leaks (programs do not
implicitly retain memory over time).
.
To ensure these properties, Rattus uses the type modality
@O@ to express the concept of time at the type
level. Intuitively speaking, a value of type @O a@
represents a computation that will produce a value of type
@a@ in the next time step. Additionally, the language also
features the @Box@ type modality. A value of type @Box a@
is a time-independent computation that can be executed at
any time to produce a value of type @a@.
.
For example, the type of streams is defined as
.
> data Str a = a ::: (O (Str a))
.
So the head of the stream is available now, but its tail
is only available in the next time step. Writing a @map@
function for this type of streams, requires us to use the
@Box@ modality:
.
> map :: Box (a -> b) -> Str a -> Str b
> map f (x ::: xs) = unbox f x ::: delay (map f (adv xs))
.
This makes sure that the function @f@ that we give to
@map@ is available at any time in the future.
.
The core of the language is defined in the module
"Rattus.Primitives". Note that the operations on @O@ and
@Box@ have non-standard typing rules. Therefore, this
library provides a compiler plugin that checks these
non-standard typing rules. To write Rattus programs, one
must enable this plugin via the GHC option
@-fplugin=Rattus.Plugin@, e.g. by including the following
line in the source file:
.
> {-# OPTIONS -fplugin=Rattus.Plugin #-}
.
In addition, one must annotate the functions that are
written in Rattus:
.
> {-# ANN myFunction Rattus #-}
.
Or annotate the whole module as a Rattus module:
.
> {-# ANN module Rattus #-}
.
Below is a minimal Rattus program using the
"Rattus.Stream" module for programming with streams:
.
> {-# OPTIONS -fplugin=Rattus.Plugin #-}
>
> import Rattus
> import Rattus.Stream
>
> {-# ANN sums Rattus #-}
> sums :: Str Int -> Str Int
> sums = scan (box (+)) 0
.
The
<docs/src/Rattus.Stream.html source code of the Rattus.Stream module>
provides more examples on how to program in Rattus.
homepage: https://github.com/pa-ba/Rattus
bug-reports: https://github.com/pa-ba/Rattus/issues
License: BSD3
License-file: LICENSE
copyright: Copyright (C) 2020 Patrick Bahr
Author: Patrick Bahr
maintainer: Patrick Bahr <[email protected]>
stability: experimental
build-type: Custom
extra-source-files: CHANGELOG.md
extra-doc-files: docs/paper.pdf
custom-setup
setup-depends:
base >= 4.5 && < 5,
Cabal >= 1.18 && < 4
library
exposed-modules: Rattus
Rattus.Stream
Rattus.Strict
Rattus.Event
Rattus.Future
Rattus.ToHaskell
Rattus.Yampa
Rattus.Plugin
Rattus.Arrow
Rattus.Primitives
Rattus.Plugin.Annotation
other-modules: Rattus.Plugin.ScopeCheck
Rattus.Plugin.SingleTick
Rattus.Plugin.CheckSingleTick
Rattus.Plugin.Strictify
Rattus.Plugin.Utils
Rattus.Plugin.Dependency
Rattus.Plugin.StableSolver
build-depends: base >=4.12 && <5,
containers >= 0.5 && < 0.8,
ghc >= 8.6 && < 9.9,
simple-affine-space >= 0.2.1 && < 0.3,
transformers >= 0.5 && < 0.7
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -W
Test-Suite memory-leak
type: exitcode-stdio-1.0
main-is: MemoryLeak.hs
hs-source-dirs: test
default-language: Haskell2010
build-depends: Rattus, base
ghc-options: -fplugin=Rattus.Plugin -rtsopts
Test-Suite time-leak
type: exitcode-stdio-1.0
main-is: TimeLeak.hs
hs-source-dirs: test
default-language: Haskell2010
build-depends: Rattus, base
ghc-options: -fplugin=Rattus.Plugin -rtsopts
Test-Suite ill-typed
type: exitcode-stdio-1.0
main-is: test/IllTyped.hs
default-language: Haskell2010
build-depends: Rattus, base
ghc-options:
-fplugin=Rattus.Plugin -rtsopts
Test-Suite newly-typed
type: exitcode-stdio-1.0
main-is: test/NewlyTyped.hs
default-language: Haskell2010
build-depends: Rattus, base
ghc-options: -fplugin=Rattus.Plugin
Test-Suite well-typed
type: exitcode-stdio-1.0
main-is: WellTyped.hs
hs-source-dirs: test
default-language: Haskell2010
build-depends: Rattus, base, containers
ghc-options: -fplugin=Rattus.Plugin -rtsopts
Test-Suite rewrite
type: exitcode-stdio-1.0
main-is: Rewrite.hs
hs-source-dirs: test
default-language: Haskell2010
build-depends: Rattus, base, containers
ghc-options: -fplugin=Rattus.Plugin -rtsopts