File: serialize.sml

package info (click to toggle)
mlton 20130715-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 60,900 kB
  • ctags: 69,386
  • sloc: xml: 34,418; ansic: 17,399; lisp: 2,879; makefile: 1,605; sh: 1,254; pascal: 256; python: 143; asm: 97
file content (31 lines) | stat: -rw-r--r-- 637 bytes parent folder | download | duplicates (7)
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
open MLton

val l = [1, 2, 3, 4]

structure W = Word8
structure V = Word8Vector

val r = ref 0
val t = (r, r)

fun pv v = (V.app (fn w => (print(W.toString w); print " ")) v
            ; print "\n")

fun pr s = (print s; print "\n")

fun pi i = (print(Int.toString i); print " ")
fun pl l = List.app pi l

fun 'a ds(a: 'a): 'a = deserialize(serialize a)
val pb = pr o Bool.toString
   
val _ =
   (pb(serialize l = serialize l)
    ; pl(ds l) ; print "\n"
    ; pb(l = ds l)
    ; pb(let val t: int ref * int ref = ds t
         in #1 t = #2 t
         end)
    ; pi(ds (fn x => x) 13)
    ; pi(ds (fn x => x + 1) 14)
    ; print "\n")