Is there a way to pattern match smart constructors, outside of its module?
Something like this:
import MyModule (thing)
fn (thing 3) = True
without being able to write this:
fn (Thing 3) = True
where thing is a smart constructor for Thing.
Define this in MyModule and export it:
extract :: Thing -> Int
extract (Thing x) = x
Use the view patterns extension:
{-# LANGUAGE ViewPatterns #-}
fn :: Thing -> Bool
fn (extract -> 3) = True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With