@@ -80,7 +80,7 @@ built on a foundation of machine code, or at the very least, `C`.
80
80
Consider the ubiquitous `vector` library:
81
81
82
82
~~~~~{.ghci}
83
- ghci> :m +Data.Vector
83
+ ghci> :m +Data.Vector
84
84
ghci> let v = fromList ["haskell", "ocaml" ]
85
85
ghci> unsafeIndex v 0
86
86
"haskell"
@@ -110,7 +110,7 @@ Finally, for certain kinds of programs, there is a fate worse than death.
110
110
is used, for example, to build web services.
111
111
112
112
~~~~~{.ghci}
113
- ghci> :m +Data.Text Data.Text.Unsafe
113
+ ghci> :m +Data.Text Data.Text.Unsafe
114
114
ghci> let t = pack "Voltage"
115
115
ghci> takeWord16 5 t
116
116
"Volta"
@@ -144,7 +144,7 @@ there are fast *decision procedures* called SMT solvers.
144
144
\newthought {By combining types with predicates} you can specify *contracts*
145
145
which describe valid inputs and outputs of functions. The refinement
146
146
type system *guarantees at compile-time* that functions adhere to
147
- their contracts. That is, you can rest assured that
147
+ their contracts. That is, you can rest assured that
148
148
the above calamities *cannot occur at run-time*.
149
149
150
150
\newthought {LiquidHaskell} is a Refinement Type Checker for Haskell, and in
@@ -190,7 +190,7 @@ solver, e.g. one of
190
190
+ [Z3][z3] (which we recommend)
191
191
+ [CVC4][cvc4]
192
192
+ [MathSat][mathsat]
193
-
193
+
194
194
\newthought {This Tutorial} is written in literate Haskell and
195
195
the code for it is available [here][liquid-tutorial].
196
196
Hence, we *strongly* recommend you grab the code, and follow
@@ -208,7 +208,7 @@ git clone --recursive https://github.com/ucsd-progsys/liquidhaskell-tutorial.git
208
208
cabal v2-build
209
209
~~~~~
210
210
211
- or
211
+ or
212
212
213
213
~~~~~{.sh}
214
214
stack build --fast --file-watch
@@ -219,49 +219,39 @@ compilation will stop with a Liquid type error:
219
219
220
220
~~~~~{.spec}
221
221
src/Tutorial_01_Introduction.lhs:30:27: error:
222
- Liquid Type Mismatch
223
- .
224
- The inferred type
222
+ Liquid Type Mismatch
223
+ .
224
+ The inferred type
225
225
VV : {v : GHC.Types.Int | v >= 0
226
226
&& v == len xs}
227
- .
227
+ .
228
228
is not a subtype of the required type
229
229
VV : {VV : GHC.Types.Int | VV /= 0}
230
- .
231
- in the context
230
+ .
231
+ in the context
232
232
xs : {v : [GHC.Types.Int] | len v >= 0}
233
- |
233
+ |
234
234
30 | average xs = sum xs `div` length xs
235
235
| ^^^^^^^^^
236
236
~~~~~
237
237
238
- **Step 3:** Iteratively edit-compile until the code in `src/`
239
-
238
+ **Step 3:** Iteratively edit-compile the code in `src/`
240
239
until it _builds_ without any liquid type errors.
241
240
242
- The above workflow will let you use whatever GHC/Haskell tooling you use for your
241
+ The above workflow will let you use whatever GHC/Haskell tooling you use for your
243
242
favorite editor, to automatically display LH errors as well.
244
243
245
- Sample Code
246
- -----------
247
-
248
- This tutorial is written in literate Haskell and
249
- the code for it is available [here][liquid-tutorial].
250
-
251
- We *strongly* recommend you grab the code, and follow
252
- along, and especially that you do the exercises.
253
-
254
- If you'd like to copy and paste code snippets into the
244
+ If you'd like to copy and paste code snippets into the
255
245
web demo, instead of cloning the repo, note that you may
256
246
need to pass `--no-termination` to `liquid`, or equivalently,
257
- add the pragma `{-@ LIQUID "--no-termination" @-}` to the top
258
- of the source file. (By default, `liquid` tries to ensure that
259
- all code it examines will terminate. Some of the code in this
260
- tutorial is written in such a way that termination is not
261
- immediately obvious to LH.)
262
-
263
- **Note:** This tutorial is a *work in progress*, and we will
264
- be **very** grateful for feedback and suggestions, ideally
247
+ add the pragma `{-@ LIQUID "--no-termination" @-}` to the top
248
+ of the source file. (By default, `liquid` tries to ensure that
249
+ all code it examines will terminate. Some of the code in this
250
+ tutorial is written in such a way that termination is not
251
+ immediately obvious to LH.)
252
+
253
+ **Note:** This tutorial is a *work in progress*, and we will
254
+ be **very** grateful for feedback and suggestions, ideally
265
255
via pull-requests on github.
266
256
267
257
\noindent Lets begin!
0 commit comments