forked from paf31/purescript-book
-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Description
-- 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
Labels
No labels