<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>
<body style="font-family:Arial;font-size:14px">
<p>Hey,<br>
<br>
a few notes:<br>
<br>
1. The (==) function in the second equation of the Maybe instance of (==) is not complete yet, since you need to match on instances of the Maybe type and "Just :: a -> Maybe a". Your idea "Just a == Just a" goes in the right direction, but please note that you can't bind two variable names ("a") in the same equation. You need to give each "boxed value" a different name. I'm sure you can work it out from there.<br>
2.  The right hand side of "(x:xs) == (y:ys)" is not implicitly recursive, but rather explicitly! Since we apply the function (==) to the smaller lists "xs" and "ys" until we arrive at a base case. <br>
<br>
Greetings,<br>
Tobias<br>
<br>
<br>
----- Nachricht von trent shipley <<a href="mailto:trent.shipley@gmail.com">trent.shipley@gmail.com</a>> ---------<br>
     Datum: Sat, 15 Sep 2018 01:23:47 -0700<br>
       Von: trent shipley <<a href="mailto:trent.shipley@gmail.com">trent.shipley@gmail.com</a>><br>
Antwort an: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>><br>
   Betreff: [Haskell-beginners] Hutton Ex 8.9.7<br>
        An: Haskell Beginners <<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>></p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
<div dir="ltr">I couldn't get close on my own.
<div> </div>
<div>From: <a href="https://github.com/pankajgodbole/hutton/blob/master/exercises.hs">https://github.com/pankajgodbole/hutton/blob/master/exercises.hs</a><br>
<div> </div>
<div>
<div><font face="monospace">{-</font></div>
<div><font face="monospace">7. Complete the following instance declarations:</font></div>
<div><font face="monospace">     instance Eq a => Eq (Maybe a) where</font></div>
<div><font face="monospace">     ...</font></div>
<div> </div>
<div><font face="monospace">     instance Eq a => Eq [a] where</font></div>
<div><font face="monospace">     ...</font></div>
<div><font face="monospace">-}</font></div>
<div><font face="monospace">-- suggested answer</font></div>
<div> </div>
<div><font face="monospace">instance Eq a => Eq (Maybe a) where</font></div>
<div><font face="monospace">  -- Defines the (==) operation.</font></div>
<div><font face="monospace">  Nothing == Nothing = True</font></div>
<div><font face="monospace">  Just    == Just    = True </font></div>
<div><font face="monospace">    -- why isn't this Just a == Just a ?</font></div>
<div><font face="monospace">    -- My guess is that a and Just a are different types and can't be == in            Haskell</font></div>
<div><font face="monospace">  _       == _       = False</font></div>
<div> </div>
<div><font face="monospace">instance Eq a => Eq [a] where</font></div>
<div><font face="monospace">  -- Defines the (==) operation.</font></div>
<div><font face="monospace">  [] == []         = True</font></div>
<div><font face="monospace">  [x] == [y]       = x == y</font></div>
<div><font face="monospace">  (x:xs) == (y:ys) = x==y && xs==ys -- I assume this is implicitly recursive.</font></div>
<div><font face="monospace">  _  == _          = False </font></div>
<div> </div>
</div>
<div> </div>
</div>
</div>
</blockquote>
<p><br>
<br>
<br>
----- Ende der Nachricht von trent shipley <<a href="mailto:trent.shipley@gmail.com">trent.shipley@gmail.com</a>> -----<br>
<br></p>
</body>
</html>