Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 12, Simple Shapes #473

Open
mkohlhaas opened this issue Nov 15, 2024 · 0 comments
Open

Chapter 12, Simple Shapes #473

mkohlhaas opened this issue Nov 15, 2024 · 0 comments

Comments

@mkohlhaas
Copy link

mkohlhaas commented Nov 15, 2024

-- The void function takes a functor and replaces its value with Unit.
-- In the example, it is used to make main conform with its signature.
main :: Effect Unit
main = void $ unsafePartial do
  Just canvas <- getCanvasElementById "canvas"
  ctx <- getContext2D canvas
main :: Effect Unit
main = unsafePartial do
  Just canvas ← getCanvasElementById "canvas"
  ctx ← getContext2D canvas
  setFillStyle ctx "#00F"
  fillPath ctx $ rect ctx
    { x: 250.0
    , y: 250.0
    , width: 300.0
    , height: 100.0
    }

void is not needed in this case b/c rect has already the desired result type:

fillPath ::  a. Context2D  Effect a  Effect a
rect :: Context2D  Rectangle  Effect Unit

Similar in other examples. void is only needed in Example.LSystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant