I'm started working with Juicy Pixels library and have some problem with deconstructing.
There are type:
data DynamicImage =
ImageY8 (Image Pixel8)
| ImageYA8 (Image PixelYA8)
| ImageRGB8 (Image PixelRGB8)
| ImageRGBA8 (Image PixelRGBA8)
| ImageYCbCr8 (Image PixelYCbCr8)
where Pixel* is instances of Pixel a class
There are some functions that work with Image a type and i wish to extract Image a from DynamicImage, but i can't
When i try to do something like
img :: (Pixel a) => DynamicImage -> Image a
img (ImageY8 i) = i
img (ImageYA8 i) = i
img (ImageRGB8 i) = i
img (ImageRGBA8 i) = i
img (ImageYCbCr8 i) = i
interpreter thwors an errors like
Couldn't match type `PixelYCbCr8' with `GHC.Word.Word8'
Expected type: Image b
Actual type: Image Pixel8
In the expression: i
In an equation for `img': img (ImageY8 i) = i
Is there any other way to extract Image a data?