ITADN

Chapter 12, Simple Shapes

#473Openmkohlhaas 创建于 2024-11-15
M
mkohlhaascommented
```PureScript -- 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 ``` ```PureScript main :: Effect Unit main = unsafePartial do Just canvas ← getCanvasElementById "canvas" ctx ← getContext2D canvas setFillStyle ctx "#08F" 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: ```PureScript fillPath :: ∀ a. Context2D → Effect a → Effect a ```
0 条评论