-
Notifications
You must be signed in to change notification settings - Fork 0
/
card.sml
58 lines (45 loc) · 1.59 KB
/
card.sml
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
structure Unitype : sig type t end = struct
datatype t = U of t (* type parameter given to untyped cards/terms/values *)
end
signature CARD = sig
type slot
type slot'
type 'a card
val untyped : 'a card -> Unitype.t card
val cast : 'a card -> 'b card (* can't be helped *)
(* combinators *)
val I : ('a -> 'a) card
val S : (('a -> 'b -> 'c) -> ('a -> 'b) -> ('a -> 'c)) card
val K : ('a -> 'b -> 'a) card
val put : ('a -> 'b -> 'b) card
(* numbers *)
val zero : int card
val succ : (int -> int) card
val dbl : (int -> int) card
(* slots *)
type field
val get : (slot -> field) card (* load from slot or fail *)
val copy : (slot -> field) card (* load from *opponent's* slot or fail *)
(* vitality *)
type u (* unit type, for things that return the identity function *)
val inc : (slot -> u) card (* increment our vitality *)
val dec : (slot' -> u) card (* decrement their vitality *)
val attack : (slot -> slot' -> int -> u) card (* decrease everyone's vitality *)
val help : (slot -> slot -> int -> u) card (* transfer vitality internally *)
val revive : (slot -> u) card (* force vitality to 1 *)
val zombie : (slot' -> field -> u) card (* create zombie in opponent *)
end
signature COMBINATORS = sig
structure Card : CARD
type 'a t
val card : 'a Card.card -> 'a t
val @@ : ('a -> 'b) t * 'a t -> 'b t
end
(* we'll need several representations *)
signature CARD_TRANSLATE = sig
structure C1 : CARD
structure C2 : CARD
exception Failed of string
val translate : 'a C1.card -> 'a C2.card
(* Could raise Failed *)
end