Skip to content

Commit

Permalink
Arduino-based IO operations were abstracted over HasIO.
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Nov 4, 2020
1 parent 71b0ea4 commit a61b977
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Blink.idr
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ infixr 9 ...
%foreign "C:digitalWrite,libarduino"
prim_digitalWrite : Int -> Int -> PrimIO Unit

digitalWrite : Int -> Int -> IO Unit
digitalWrite : HasIO io => Int -> Int -> io Unit
digitalWrite = primIO ... prim_digitalWrite

%foreign "C:pinMode,libarduino"
prim_pinMode : Int -> Int -> PrimIO Unit

pinMode : Int -> Int -> IO Unit
pinMode : HasIO io => Int -> Int -> io Unit
pinMode = primIO ... prim_pinMode

%foreign "C:delay,libarduino"
prim_delay : Int -> PrimIO Unit

delay : Int -> IO 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 : Int -> Int -> IO ()
blink : HasIO io => Int -> Int -> io ()
blink pin t = do digitalWrite pin 1
delay t
digitalWrite pin 0
Expand Down

0 comments on commit a61b977

Please sign in to comment.