-
Notifications
You must be signed in to change notification settings - Fork 2
/
Main.purs
52 lines (48 loc) · 1.46 KB
/
Main.purs
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
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log, logShow)
import Control.Monad.State (execState)
import Control.Monad.State.Trans (execStateT)
import Data.Lens ((^..))
import Game (battle, fireBreath, fireBreath', getScore, initialState, partyLoc, retreat, setScore, strike, strike', updateScore)
import Game.Data (GamePoint(..))
main :: Effect Unit
main = do
chapter "Getter / Setter"
label "get score"
logShow $ execState getScore initialState
label "set score"
logShow $ execState setScore initialState
label "update score"
logShow $ execState updateScore initialState
chapter "Composition"
label "strike"
logShow =<< execStateT strike initialState
label "strike'"
logShow =<< execStateT strike' initialState
chapter "Traversal"
label "fireBreath"
logShow =<< execStateT fireBreath initialState
label "fireBreath'"
logShow =<< execStateT (fireBreath' $ GamePoint {x: 0.5, y:1.5}) initialState
chapter "Zooming"
label "partyLoc"
logShow $ initialState ^.. partyLoc
label "retreat"
logShow =<< execStateT retreat initialState
label "retreat newstate"
execStateT retreat initialState >>= \st -> logShow $ st ^.. partyLoc
chapter "Combining"
label "battle"
logShow =<< execStateT battle initialState
label :: String -> Effect Unit
label text = do
log ""
log $ "# " <> text
chapter :: String -> Effect Unit
chapter title = do
log ""
log "~~~~~~~~~~~~~~~~~~"
log title
log "~~~~~~~~~~~~~~~~~~"