[Haskell-cafe] Pattern Matching with Different Types

Yotam Ohad yotam2206 at gmail.com
Tue Oct 10 16:56:25 UTC 2017


Hello cafe,
I am trying to do the following:

data Foo = Foo { a1 :: Int -> Int, a2 :: Int -> Char }
data Bar = Bar { a1 :: Int -> Int }

func :: a -> Maybe (Int -> Int) -- a is either Foo or Bar
func (x::(Bar/Foo) = Just $ a1 x
func _ = Nothing

I'm not sure how to implement this. All I know that the types are matching
so I think it could be possible.

Thanks for your help
-Yotam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20171010/1d63c385/attachment.html>


More information about the Haskell-Cafe mailing list