LumiGuide / haskell-opencv

Haskell binding to OpenCV-3.x
Other
154 stars 44 forks source link

Fix wrong NFData instance #135

Closed nh2 closed 5 years ago

nh2 commented 5 years ago

:rotating_light: :police_car: :rotating_light: This is the Haskell police :policeman: :stop_sign:

We have found some illegal code on your premises! :mag_right: :open_mouth: It is not law-abiding! :scroll: :point_left:

The code

rnf _ = ()

is always wrong for any instance!

Any request to evaluate to normal form must at least evaluate to weak head normal form.

Even worse in this case, the ForeignPtr inside the type is often created by unsafePerformIO, and you'd really expect that rnf enforces that.

roelvandijk commented 5 years ago

Whoops!

We probably thought it wasn't necessary to evaluate the ForeignPtr inside of the Mat because it is a newtype.

basvandijk commented 5 years ago

Whoops that was my stupid mistake.