Skip to content

Commit

Permalink
Looping was made to be using a combinator, not a direct recursion.
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed May 12, 2020
1 parent d25bb68 commit 68d2c3e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Blink.idr
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ pinMode pin mode = foreign FFI_C "pinMode" (Int -> Int -> IO ()) pin mode
delay : Int -> IO ()
delay ms = foreign FFI_C "delay" (Int -> IO ()) ms

forever : Monad f => f a -> f b
forever x = do x
forever x

blink : Int -> Int -> IO ()
blink pin t = do digitalWrite pin 1
delay t
digitalWrite pin 0
delay t
blink pin t

main : IO ()
main =
do pinMode 13 1
blink 13 30
forever $ blink 13 300

0 comments on commit 68d2c3e

Please sign in to comment.