-
Notifications
You must be signed in to change notification settings - Fork 3
/
Blink.idr
39 lines (28 loc) · 851 Bytes
/
Blink.idr
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
module Main
infixr 9 ...
%inline
(...) : (c -> d) -> (a -> b -> c) -> a -> b -> d
(...) = (.) . (.)
%foreign "C:digitalWrite,libarduino"
prim_digitalWrite : Int -> Int -> PrimIO Unit
digitalWrite : HasIO io => Int -> Int -> io Unit
digitalWrite = primIO ... prim_digitalWrite
%foreign "C:pinMode,libarduino"
prim_pinMode : Int -> Int -> PrimIO Unit
pinMode : HasIO io => Int -> Int -> io Unit
pinMode = primIO ... prim_pinMode
%foreign "C:delay,libarduino"
prim_delay : Int -> PrimIO Unit
delay : HasIO io => Int -> io Unit
delay = primIO . prim_delay
forever : Monad f => f a -> f b
forever x = do x; forever x
blink : HasIO io => Int -> Int -> io ()
blink pin t = do digitalWrite pin 1
delay t
digitalWrite pin 0
delay t
main : IO ()
main =
do pinMode 13 1
forever $ blink 13 300