File: serialize.sml

package info (click to toggle)
mlton 20100608-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 36,624 kB
  • sloc: ansic: 18,441; lisp: 2,879; makefile: 1,572; sh: 1,326; pascal: 256; 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")