Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (35 sloc) 1.199 kB
022015a Initialised repo
Edwin Brady authored
1 include "ResIO.idr";
2
3 fread' : File -> IOr String;
4 fread' x = ior (fread x);
5
6 fopen' : String -> String -> IOr (Either () File);
7 fopen' f m = ior do { h <- fopen f m;
8 return (Right h); };
9
10 fclose' : File -> IOr ();
11 fclose' f = ior (fclose f);
12
13 rread : MK_USE File String;
14 rread r = USE fread' r; %hide fread';
15
16 ropen : String -> MK_CREATE (Either () File);
17 ropen fname i = CREATE i (fopen' fname "r"); %hide fopen';
18
19 rclose : MK_UPDATE File ();
20 rclose r = UPDATE (fclose' (getResource r)) r; %hide fclose';
21
22 do using (BIND, RETURN) {
23
24 printline : ResSub File ();
25 printline h = do { str <- rread h;
26 LIFT (putStrLn str); };
27
28 oc : ResProg ();
29 oc = RP {n=resources 1}
30 do { ropen "Test" fO;
31 h <- GET fO;
32 CHECK h
33 (return II)
34 (do { h <- GET fO;
35 CALL printline h;
36 CALL printline h;
37 CALL printline h;
38 CALL printline h;
39 CALL printline h;
40 rclose h;
41 });
42 };
43 }
44
45 main = run oc;
Something went wrong with that request. Please try again.