<div dir="ltr">I'm trying to translate <i>The Little MLer </i>into Haskell. I've got this<br><div><br></div><div><font face="monospace">data Shishkebab = Skewer | Onion Shishkebab | Lamb Shishkebab | Tomato Shishkebab deriving Show<br></font></div><div><br></div><div>Then I have this which works</div><div><br></div><div><font face="monospace">veggieKebab :: Shishkebab -> Bool<br>veggieKebab Skewer = True<br>veggieKebab (Onion (shk)) = veggieKebab shk<br>veggieKebab (Tomato (shk)) = veggieKebab shk<br>veggieKebab (Lamb (shk)) = False<br></font></div><div><font face="monospace"><br></font></div><div><font face="monospace">> veggieKebab (Tomato (Onion (Tomato (Onion Skewer))))<br>True</font><br></div><div><br></div><div>but I'm wondering if I could do something like this<br></div><div><br></div><div><font face="monospace">veggieKebab :: Shishkebab -> Bool<br>veggieKebab Skewer = True<br>veggieKebab (shkb (sk)) | (shkb == Onion) || (shkb == Tomato) = veggieKebab sk<br>                        | otherwise = False</font><br></div><div><br></div><div><br></div><div>This doesn't work, giving a <font face="monospace">"Parse error in pattern: shkb"</font>. I've been advised that I'm trying to treat what is a data constructor like a variable, but I can't fathom what that means in this case. What I'm trying to leverage is what I've learned from dealing with lists and recursion through the consed list. So if effect I'm trying to recurse through a consed Shishkebab object. It works in the first case, but hyow could I do this in this more generic way like the second try does?</div><div><br></div><div>LB</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>