paf31 / purescript-book

Sources for the PureScript book
454 stars 370 forks source link

Errors in Chapter 9 examples #102

Closed gabejohnson closed 7 years ago

gabejohnson commented 7 years ago
A result of type

      Context2D

    was implicitly discarded in a do notation block.
    You can use _ <- ... to explicitly discard the result.

  while applying a function discard
    of type Discard t0 => Bind t1 => t1 t0 -> (t0 -> t1 t2) -> t1 t2
    to argument (setFillStyle "#0000FF") ctx
  while inferring the type of discard ((setFillStyle "#0000FF") ctx)
  in value declaration main

  where t0 is an unknown type
        t2 is an unknown type
        t1 is an unknown type

There are implicit discards like this at:

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Rectangle.purs#L16

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Refs.purs#L21-L23

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Refs.purs#L30

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Refs.purs#L36-L41

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Refs.purs#L59

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Shapes.purs#L29-L53

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/LSystem.purs#L54-L55

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/LSystem.purs#L61

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Random.purs#L20-L21

https://github.com/paf31/purescript-book/blob/b1790a9b7e977c2104b83f410f32d829e751d21b/exercises/chapter9/src/Example/Random.purs#L36

gabejohnson commented 7 years ago

@paf31 it might make more sense to just add a Discard instance for Context2D as mentioned in https://github.com/purescript-contrib/purescript-canvas/issues/42