| ... | @@ -64,3 +64,14 @@ The only real change is that some of the default declarations are provided gener |
... | @@ -64,3 +64,14 @@ The only real change is that some of the default declarations are provided gener |
|
|
[ http://haskell.org/haskellwiki/GHC/Stand-alone_deriving_declarations](http://haskell.org/haskellwiki/GHC/Stand-alone_deriving_declarations) contains a great discussion of some of these ideas. (NB. Section 3 is misleading: leaving the clauses out of an instance declaration *does not* leave all the methods undefined; rather it gives the default methods of the class).
|
|
[ http://haskell.org/haskellwiki/GHC/Stand-alone_deriving_declarations](http://haskell.org/haskellwiki/GHC/Stand-alone_deriving_declarations) contains a great discussion of some of these ideas. (NB. Section 3 is misleading: leaving the clauses out of an instance declaration *does not* leave all the methods undefined; rather it gives the default methods of the class).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
As there are only a few fixed methods/classes that can be derived, we may choose not to have any special syntax for the few derived methods, but just put a comment in the code:
|
|
|
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
class Eq a where
|
|
|
|
(==) :: a -> a -> Bool
|
|
|
|
(/=) :: a -> a -> Bool
|
|
|
|
-- (==) has a magic way of be derived for datatypes
|
|
|
|
x /= y = not (x == y)
|
|
|
|
``` |
|
|
|
\ No newline at end of file |