-- Definition of the data structures ---------------------------------------- -- a triple is made with a subject, a verb and an object , -- or it is null data Triple = Triple Subject Verb Object| TripleNull -- a triple list can be null data TripleList = TripleList [Triple]| TripleListNull -- a subject is an atom, a triple , a list of triples or null data Subject = SubjectAtom Atom| SubjectTriple Triple| SubjectTripleList TripleList| SubjectNull -- a verb is an atom, a triple or a list of triples data Verb = Verb Atom -- an object is an atom data Object = Object Atom -- an atom is an uri or a variable -- int is an entry into a list [x,y, ...] where x and y are strings . -- we have an uri-list and an atom list -- an atom can have a propertylist data Atom = Uri Int| Var Int| FullUri Int PropertyList| FullVar Int PropertyList| NullAtom -- a propertylist contains properies of atoms like a reference -- to another atom data PropertyList = Prop Ref -- the input is a list of triples type Input = [Triple] -- a rule is a tuple made of an input and a triple . type Rule = (Input, Triple) -- a query is a list of triples type Query = [Triple] -- a goallist is a list of triples type GoalList = [Triple] -- a goal is a triple type Goal = Triple -- a reference is an atom type Ref = Atom -- Functions ---------------- -- unification takes as input two triples and produces a triple unify :: Triple -> Triple -> Triple unify Null Null = Null unify Null t2 = t2 unify t1 Null = t1 -- Example data ------------------ -- unify test t1 = Triple (Subject (Var 1)) (Verb (Uri 1)) (Object (Var 2)) t2 = Triple (Subject (Var 3)) (Verb (Var 4)) (Object (Uri 2))