git.iko.soy/rowtype-yoga/purescript-backend-optimizer
on main help sign in
37 lines 817 B history raw
1module Snapshot.EffectLoops03 where
3import Prelude
5import Effect (Effect, whileE)
6import Effect.Class.Console as Console
7import Effect.Ref (Ref)
8import Effect.Ref as Ref
10test1 :: Ref Boolean -> Effect Unit
11test1 cond = whileE (Ref.read cond) do
12 Console.log "foo"
13 Console.log "bar"
15test2 :: Ref Boolean -> Effect Unit
16test2 cond = do
17 whileE (Ref.read cond) do
18 Console.log "foo"
19 whileE (Ref.read cond) do
20 Console.log "bar"
22test3 :: Ref Boolean -> Ref Int -> Effect Unit
23test3 cond ref = do
24 whileE (Ref.read cond) do
25 a <- Ref.read ref
26 when (a < 10) do
27 Console.log "foo"
29test4 :: Ref Boolean -> Ref Int -> Effect Unit
30test4 cond ref = do
31 whileE (Ref.read cond) do
32 a <- Ref.read ref
33 void $
34 if a < 10 then
35 Console.log "foo"
36 else
37 Console.log "wat"