Permalink
Browse files

[fix] Missing coercions to force abstraction in interface with @private

… types.
  • Loading branch information...
1 parent 53d6c87 commit bbc9a9d7229044bc2414868f41cb7e442ac1dcaf @fpessaux fpessaux committed Apr 26, 2011
Showing with 15 additions and 15 deletions.
  1. +14 −14 src/colset.opa
  2. +1 −1 src/grid.opa
View
@@ -26,20 +26,20 @@ type ColSet.t = int
@both @public ColSet = {{
- empty = 0
+ empty = 0 : ColSet.t
- is_empty(set) = set == empty
+ is_empty(set : ColSet.t) = set == empty
- mem(i, set) =
+ mem(i : ColSet.elt, set : ColSet.t) : ColSet.elt =
Int.land(1, Int.lsr(set, i))
- add(i, set) =
+ add(i : ColSet.elt, set : ColSet.t) : ColSet.t =
Int.lor(set, Int.lsl(1, i))
- inter = Int.land
- union = Int.lor
+ inter = Int.land : ColSet.elt, ColSet.elt -> ColSet.elt
+ union = Int.lor : ColSet.elt, ColSet.elt -> ColSet.elt
- fold(fold, set, acc) =
+ fold(fold, set : ColSet.t, acc) =
rec aux(elt, set, acc) =
if set == 0 then acc
else
@@ -50,23 +50,23 @@ type ColSet.t = int
aux(succ(elt), Int.lsr(set, 1), acc)
aux(0, set, acc)
- map(map, set) =
+ map(map, set : ColSet.t) : ColSet.t =
aux(elt, set) = add(map(elt), set)
fold(aux, set, empty)
- iter(iter, set) =
+ iter(iter, set : ColSet.t) =
aux(elt, _) = iter(elt) : void
fold(aux, set, void)
- elements(set) =
+ elements(set : ColSet.t) : list(ColSet.elt) =
list = fold(List.cons, set, List.empty)
List.rev(list)
- size(set) =
+ size(set : ColSet.t) =
aux(_, acc) = succ(acc)
fold(aux, set, 0)
- to_string(set) =
+ to_string(set : ColSet.t) =
cons(hd, tl) = List.cons(string_of_int(hd), tl)
list = fold(cons, set, List.empty)
List.to_string(List.rev(list))
@@ -75,15 +75,15 @@ type ColSet.t = int
* Folding intersection, but ignoring sets which
* make the intersection become empty.
**/
- specialize(setA, setB) =
+ specialize(setA : ColSet.t, setB : ColSet.t) =
inter = inter(setA, setB)
if is_empty(inter) then setA else inter
/**
* Pick a random elt in the set.
* Returns { none } if the set is empty
**/
- random(set) =
+ random(set : ColSet.t) : option(ColSet.elt) =
rec aux(elt, set, size) =
if set == 0 then none
else
View
@@ -108,7 +108,7 @@ type Grid.t('content) = {
/**
* Creating a new grid form [dimensions] and a default [content].
**/
- make(dimensions : Grid.dimensions, content) =
+ make(dimensions : Grid.dimensions, content) : Grid.t =
c = dimensions.columns
l = dimensions.lines
line() = LowLevelArray.create(l, content)

0 comments on commit bbc9a9d

Please sign in to comment.