[Working on chapter 5 John Goerzen **20070603212324] { adddir ./examples/ch05 hunk ./en/00book.xml 19 + hunk ./en/ch05-typeclasses.xml 19 - you resolved to implement your own equality tests. Your program + you resolved to implement your own equality tests. Your application hunk ./en/ch05-typeclasses.xml 22 - this: + . + + + Naive Equality naiveeq.hs + &naiveeq.hs:color; + + + You can test this with ghci or + hugs: + + +$ ghci naiveeq.hs +Loading package base ... linking ... done. +[1 of 1] Compiling Main ( naiveeq.hs, interpreted ) +Ok, modules loaded: Main. +*Main> colorEq Red Red +True +*Main> colorEq Red Blue +False + + + Now, let's say that you want to add addfile ./examples/ch05/naiveeq.hs hunk ./examples/ch05/naiveeq.hs 1 +{-- snippet color --} +data Color = Red | Green | Blue + +colorEq :: Color -> Color -> Bool +colorEq Red Red = True +colorEq Red _ = False +colorEq Green Green = True +colorEq Green _ = False +colorEq Blue Blue = True +colorEq Blue _ = False +{-- /snippet color --} + }