Skip to content

Chapter 12, Simple Shapes #473

@mkohlhaas

Description

@mkohlhaas
-- 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions