1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
module Data.Derive.Eq where
{-
import Prelude
example :: Sample
instance (Eq a) => Eq (Sample a) where
First == First = True
Second x1 x2 == Second y1 y2 = x1 == y1 && x2 == y2 && True
Third x1 == Third y1 = x1 == y1 && True
_ == _ | length [First{},Second{},Third{}] > 1 = False
test :: Assoced
instance Eq typ => Eq (Assoced typ) where
Assoced x1 x2 == Assoced y1 y2 = x1 == y1 && x2 == y2
test :: TwoParam
instance Eq b => Eq (TwoParam a b) where
TwoParam x1 == TwoParam y1 = x1 == y1
-}
-- GENERATED START
import Data.Derive.DSL.DSL
import Data.Derive.Internal.Derivation
makeEq :: Derivation
makeEq = derivationDSL "Eq" dslEq
dslEq =
List [Instance ["Eq"] "Eq" (List [App "InsDecl" (List [App
"FunBind" (List [Concat (List [MapCtor (App "Match" (List [App
"Symbol" (List [String "=="]),List [App "PApp" (List [App "UnQual"
(List [App "Ident" (List [CtorName])]),MapField (App "PVar" (List
[App "Ident" (List [Concat (List [String "x",ShowInt FieldIndex])]
)]))]),App "PApp" (List [App "UnQual" (List [App "Ident" (List [
CtorName])]),MapField (App "PVar" (List [App "Ident" (List [Concat
(List [String "y",ShowInt FieldIndex])])]))])],App "Nothing" (List
[]),App "UnGuardedRhs" (List [Fold (App "InfixApp" (List [Head,App
"QVarOp" (List [App "UnQual" (List [App "Symbol" (List [String
"&&"])])]),Tail])) (Concat (List [MapField (App "InfixApp" (List [
App "Var" (List [App "UnQual" (List [App "Ident" (List [Concat (
List [String "x",ShowInt FieldIndex])])])]),App "QVarOp" (List [
App "UnQual" (List [App "Symbol" (List [String "=="])])]),App
"Var" (List [App "UnQual" (List [App "Ident" (List [Concat (List [
String "y",ShowInt FieldIndex])])])])])),List [App "Con" (List [
App "UnQual" (List [App "Ident" (List [String "True"])])])]]))]),
App "BDecls" (List [List []])])),List [App "Match" (List [App
"Symbol" (List [String "=="]),List [App "PWildCard" (List []),App
"PWildCard" (List [])],App "Nothing" (List []),App "GuardedRhss" (
List [List [App "GuardedRhs" (List [List [App "Qualifier" (List [
App "InfixApp" (List [App "App" (List [App "Var" (List [App
"UnQual" (List [App "Ident" (List [String "length"])])]),App
"List" (List [MapCtor (App "RecConstr" (List [App "UnQual" (List [
App "Ident" (List [CtorName])]),List []]))])]),App "QVarOp" (List
[App "UnQual" (List [App "Symbol" (List [String ">"])])]),App
"Lit" (List [App "Int" (List [Int 1])])])])],App "Con" (List [App
"UnQual" (List [App "Ident" (List [String "False"])])])])]]),App
"BDecls" (List [List []])])]])])])])]
-- GENERATED STOP
|