Permalink
Browse files

[clean-up] following some FIXME(s)

  • Loading branch information...
1 parent 56edc59 commit 1264928ac3e32f9228ddb0687f71caab302d4b02 Mathieu Barbin committed Mar 28, 2011
Showing with 33 additions and 21 deletions.
  1. +9 −10 multitub/multitub.opa
  2. +9 −3 src/client.opa
  3. +15 −8 src/game.opa
View
@@ -121,8 +121,7 @@ type Multitub.S.channel = channel(Multitub.private.S.message)
* }}
* ]}
**/
-// FIXME: should be a module interface
-type Multitub.C.interface('state) = {
+type Multitub.C.interface('state) = {{
/**
* Create the internal state of the client.
@@ -159,7 +158,7 @@ type Multitub.C.interface('state) = {
* not be used.
**/
page : Multitub.S.channel, Multitub.C.channel -> xhtml
-}
+}}
/**
* {2 Server}
@@ -176,8 +175,7 @@ type Multitub.C.interface('state) = {
* }}
* ]}
**/
-// FIXME: should be a module interface
-type Multitub.S.interface('state) = {
+type Multitub.S.interface('state) = {{
/**
* Create the internal state of the server.
@@ -206,7 +204,7 @@ type Multitub.S.interface('state) = {
* use the function [Multitub.send_client] on the client channel.
**/
on_message : Multitub.C.channel, 'state, Multitub.S.message -> Session.instruction('state)
-}
+}}
/**
@@ -255,11 +253,12 @@ type Multitub.private.C.state('state) = {
/**
* Maping instructions for sub-state manipulation.
**/
-@private session_map_instruction(map, i) =
- match i : Session.instruction with
+@private session_map_instruction(map : 'a -> 'b, i) : Session.instruction('b) =
+ match i : Session.instruction('a) with
| {set = state} -> {set = map(state)}
- | {unchanged}
- | {stop} -> Magic.id(i) : Session.instruction // Fixme: do something with the typer
+ | {unchanged} as i
+ | {stop} as i
+ -> i
/**
* {2 Client}
View
@@ -202,8 +202,13 @@ set_content(location : Grid.location, content : Game.content) =
token = ClientToken.token(location)
match content with
| {free} -> ClientToken.clear(token)
- | _ ->
- player = FixTheTyper.player_of_content(content)
+ // FIXME: replace by the following line, once available in OPA
+ /*
+ | ( { R } | { Y } ) as player ->
+ */
+ | { R } as player
+ | { Y } as player ->
+ // end of FIXME
ClientToken.colorize(token, player)
get_content(location : Grid.location) =
@@ -295,7 +300,8 @@ xhtml(s_channel : Multitub.S.channel, c_channel : Multitub.C.channel) =
/**
* Build the complete page.
- * <!> FIXME: this function cannot comport any jlog, it cause a looping initialization.
+ * <!> FIXME: this function cannot comport any jlog,
+ * it cause a looping initialization.
**/
page(s_channel : Multitub.S.channel, c_channel : Multitub.C.channel) =
xhtml =
View
@@ -169,17 +169,17 @@ type Game.state = {
| { R } -> { Y }
| { Y } -> { R }
- neg(content) =
+ neg(content) : Game.content =
match content : Game.content with
| { free } -> content
- | player ->
- @opensums(neg_player(FixTheTyper.player_of_content(player))) : Game.content
+ | { R } -> { Y }
+ | { Y } -> { R }
compare_player(p1 : Game.player, p2 : Game.player) =
- compare(@opensums(p1) : Game.content, @opensums(p2) : Game.content)
+ compare(p1 <: Game.content, p2 <: Game.content)
equal_player(p1 : Game.player, p2 : Game.player) =
- equal(@opensums(p1) : Game.content, @opensums(p2) : Game.content)
+ equal(p1 <: Game.content, p2 <: Game.content)
}}
@@ -257,21 +257,28 @@ type Game.state = {
lines = GameParameters.dimensions.lines
match Grid.getij(grid, i, j) with
| {free} -> none
+
+ // FIXME: replace by the following, once it will be available in OPA:
+ /*
+ | ( { R } | { Y } ) as player
+ */
| player ->
+ player = FixTheTyper.player_of_content(player)
+ // end of FIXME
+
di = direction.column
dj = direction.line
rec aux(dst, i, j) =
// do jlog(" aux(dst:{dst}, {i}, {j}, di:{di}, dj:{dj})")
if dst >= goal
then
- player = FixTheTyper.player_of_content(player)
some(player)
else
if (i < 0) || (j < 0) || (i >= columns) || (j >= lines)
then none
else
content = Grid.getij(grid, i, j)
- if GameContent.equal(content, player)
+ if GameContent.equal(content, player <: Game.content)
then aux(succ(dst), i+di, j+dj)
else none
aux(1, i+di, j+dj) : option(Game.player)
@@ -433,7 +440,7 @@ type Game.state = {
the type to {b Game.content} is a handy workaround against the
current @opensums bug in the typechecker
(see test 02-subsums.opa).
- However, FIXME: @opensums(player) : Game.content */
+ However, FIXME: player <: Game.content */
content = (player : Game.player) <: Game.content
grid = Grid.set(grid, location, content)
status = GameRules.status(grid)

0 comments on commit 1264928

Please sign in to comment.