Skip to content

Commit

Permalink
Fix invaders for export rules
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinb committed May 18, 2016
1 parent 0d3d899 commit ac34d09
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Effects/Expr.idr
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ data Expr = Var String
Env : Type
Env = List (String, Integer)

getRnd : Integer -> Eff Integer [RND]
getRnd : Integer -> Eff Integer [RND, STDIO]
getRnd upper = rndInt 0 upper

eval : Expr -> Eff Integer [EXCEPTION String, STDIO, RND, STATE Env]
eval : Expr -> Eff Integer [STDIO, EXCEPTION String, STATE Env, RND]
eval (Var x)
= case lookup x !get of
Nothing => raise ("No such variable " ++ x)
Expand All @@ -33,7 +33,7 @@ testExpr = Add (Add (Var "foo") (Val 42)) (Random 100)

runEval : List (String, Integer) -> Expr -> IO Integer
runEval args expr = run (eval' expr)
where eval' : Expr -> Eff Integer [EXCEPTION String, STDIO, RND, STATE Env]
where eval' : Expr -> Eff Integer [EXCEPTION String, RND, STDIO, STATE Env]
eval' e = do put args
srand 1234
eval e
Expand Down
2 changes: 2 additions & 0 deletions Invaders/Aliens.idr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Aliens
import Effect.SDL
import Effects

%access public export

record Alien where
constructor MkAlien
position : (Int, Int)
Expand Down
2 changes: 2 additions & 0 deletions Invaders/Gamestate.idr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Effect.StdIO
import Aliens
import Rnd

%access public export

record Gamestate where
constructor MkGamestate
position : (Int, Int)
Expand Down
6 changes: 2 additions & 4 deletions Invaders/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ emain = do putStrLn "Initialising"
quit
where
draw : Running ()
draw = with Effects do
rectangle black 0 0 640 480
draw = do rectangle black 0 0 640 480
drawStarfield !(Starfield :- get)
gs <- Gamestate :- get
drawBullets (bullets gs)
Expand Down Expand Up @@ -76,12 +75,11 @@ emain = do putStrLn "Initialising"
eventLoop = do draw
updateWorld
when !(process !poll) eventLoop


main : IO ()
main = runInit [(), Frames := 0,
Gamestate := initState,
Starfield := List.Nil,
1234567890,
()] emain


2 changes: 2 additions & 0 deletions Invaders/Rnd.idr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Rnd

import Effects

%access public export

data Random : Effect where
GetRandom : Random Int Int (\v => Int)

Expand Down
2 changes: 2 additions & 0 deletions Invaders/Starfield.idr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Effect.State

import Rnd

%access public export

data Starfield : Type where -- for labelling state

StarEff : Type -> Type
Expand Down

0 comments on commit ac34d09

Please sign in to comment.