2 ms·
Author here.. Just as a preview of the next release of this, I've been teaching it how different pins of the arduino can be used. Some pins support digital IO,
by joeyh 7y ago
Author here.. Just as a preview of the next release of this, I've been teaching it how different pins of the arduino can be used. Some pins support digital IO, some also PWM, some analog input pins also support digital IO, but others don't.
So I can write a program like this and pick pins to use essentially at random:
import Copilot.Arduino.Uno
main :: IO ()
main = arduino $ do
pwm pin2 =: longer_and_longer
delay =: constant 10
And without even needing to load it into a board, let alone hook up wires, the compiler can tell me it won't work:
demo2.hs:5:9: error:
• This Pin does not support PWM
• In the first argument of ‘(=:)’, namely ‘pwm pin2’
In a stmt of a 'do' block: pwm pin2 =: longer_and_longer
This is implemented using type level lists and type level programming, and user-defined type error messages.