@@ -115,11 +115,11 @@ E ::=
115115 fun '(X : T) => E (implicit function/functor/constructor)
116116 E E (application)
117117 if E then E else E : T (conditional)
118- wrap E : T (impredicative wrapping)
119- unwrap E : T (unwrapping)
118+ E :# T (impredicative wrapping)
119+ E # : T (unwrapping)
120120 rec (X : T) => E (recursion)
121- @T E (recursive type roll)
122- E.@T (recursive type unroll)
121+ E :@ T (recursive type roll)
122+ E @: T (recursive type unroll)
123123 import "path" (static import of module from file at path)
124124
125125(bindings)
@@ -192,7 +192,7 @@ E ::= ...
192192 E1 || E2 ~> if E1 then true else E2
193193 E1 && E2 ~> if E1 then E2 else false
194194 E : T ~> (fun (X : T) => X) E
195- E :> T ~> unwrap (wrap E : T) : T
195+ E :> T ~> E :# T # : T
196196 let B in E ~> {B , X = E}.X
197197 rec P => E ~> rec (X : TP) => let P = X in E [2]
198198 E1 ; E2 ~> let _ = E1 in E2
@@ -209,8 +209,8 @@ P ::=
209209 (P1, ..., Pn) ~> {_1 = P1, ..., _n = Pn}
210210 (type X A1 ... An) ~> (X : A1 -> ... -> An -> type)
211211 (type (A1 SYM A2) A3 ... An) ~> (type (SYM) A1 ... An)
212- wrap P : T ~> ...let $ = unwrap $ : T in {P = $}
213- @T P ~> ...let $ = $.@ T in {P = $}
212+ P :# T ~> ...let $ = $ # : T in {P = $}
213+ P :@ T ~> ...let $ = $ @: T in {P = $}
214214 P : T ~> P = $ : T
215215 P1 as P2 ~> P1, P2
216216
@@ -344,11 +344,11 @@ There are no datatype definitions, recursive types have to be defined
344344explicitly, and require explicit injection/projection.
345345
346346``` 1ml
347- type stream = rec t => {hd : int, tl : () ~> opt t} ;; creates rec type
348- single x = @ stream{hd = x, tl = fun () => none} ;; @(t) e rolls value into t
349- @stream {hd = n} = single 5 ;; @(t) p pattern matches on rec value
347+ type stream = rec t => {hd : int, tl : () ~> opt t} ;; creates rec type
348+ single x :@ stream = {hd = x, tl = fun () => none} ;; b :@ t rolls value into t
349+ ( {hd = n} :@ stream) = single 5 ;; p :@ t pattern matches on rec value
350350do Int.print n ;; or:
351- do Int.print (single 7).@ stream.hd ;; e.@(t) unrolls rec value directly
351+ do Int.print (single 7 @: stream) .hd ;; e @: t unrolls rec value directly
352352```
353353
354354#### Recursive Functions
@@ -360,15 +360,15 @@ count = rec self => fun i =>
360360 if i == 0 then () else self (i - 1)
361361
362362repeat = rec self => fun x =>
363- @stream {hd = x, tl = fun () => some (self x)}
363+ {hd = x, tl = fun () => some (self x)} :@ stream
364364```
365365
366366Mutual recursion is also expressible:
367367
368368``` 1ml
369369{even, odd} = rec (self : {even : int ~> stream, odd : int ~> stream}) => {
370- even x = @ stream{hd = x, tl = fun () => some (self.odd (x + 1))}
371- odd x = @ stream{hd = x, tl = fun () => some (self.even (x + 1))}
370+ even x :@ stream = {hd = x, tl = fun () => some (self.odd (x + 1))}
371+ odd x :@ stream = {hd = x, tl = fun () => some (self.even (x + 1))}
372372}
373373```
374374
@@ -392,14 +392,13 @@ Opt :> OPT = {
392392 ;; Church encoding; it requires the abstract type opt a to be implemented
393393 ;; with a polymorphic (i.e., large) type. Thus, wrap the type.
394394 type opt a = wrap (b : type) -> b -> (a ~> b) ~> b
395- none = wrap ( fun (b : type) (n : b) (s : _ ~> b) => n) : opt _
396- some x = wrap ( fun (b : type) (n : b) (s : _ ~> b) => s x) : opt _
397- caseopt xo = (unwrap xo : opt _) _
395+ none :# opt _ = fun (b : type) (n : b) (s : _ ~> b) => n
396+ some x :# opt _ = fun (b : type) (n : b) (s : _ ~> b) => s x
397+ caseopt ( xo :# opt _) = xo _
398398}
399399```
400400
401- Note how values of type ` wrap T ` have to be wrapped and unwrapped explicitly,
402- with a type annotation.
401+ Note how values of type ` wrap T ` have to be wrapped and unwrapped explicitly.
403402
404403---
405404
0 commit comments