@@ -50,58 +50,58 @@ class (Eq a, NFData a, Binary a, Show a) => Atomable a where
5050 toAtomType v = toAtomTypeG (from v)
5151
5252 -- | Creates DatabaseContextExpr necessary to load the type constructor and data constructor into the database.
53− toDatabaseContextExpr :: a -> DatabaseContextExpr
54− default toDatabaseContextExpr :: (Generic a, AtomableG (Rep a)) => a -> DatabaseContextExpr
55− toDatabaseContextExpr v = toDatabaseContextExprG (from v) (toAtomType v)
53+ toAddTypeExpr :: a -> DatabaseContextExpr
54+ default toAddTypeExpr :: (Generic a, AtomableG (Rep a)) => a -> DatabaseContextExpr
55+ toAddTypeExpr v = toAddTypeExprG (from v) (toAtomType v)
5656
5757instance Atomable Int where
5858 toAtom = IntAtom
5959 fromAtom (IntAtom i) = i
6060 fromAtom e = error ("improper fromAtom" ++ show e)
6161 toAtomType _ = IntAtomType
62− toDatabaseContextExpr _ = NoOperation
62+ toAddTypeExpr _ = NoOperation
6363
6464instance Atomable Double where
6565 toAtom = DoubleAtom
6666 fromAtom (DoubleAtom d) = d
6767 fromAtom _ = error "improper fromAtom"
6868 toAtomType _ = DoubleAtomType
69− toDatabaseContextExpr _ = NoOperation
69+ toAddTypeExpr _ = NoOperation
7070
7171instance Atomable T.Text where
7272 toAtom = TextAtom
7373 fromAtom (TextAtom t) = t
7474 fromAtom _ = error "improper fromAtom"
7575 toAtomType _ = TextAtomType
76− toDatabaseContextExpr _ = NoOperation
76+ toAddTypeExpr _ = NoOperation
7777
7878instance Atomable Day where
7979 toAtom = DayAtom
8080 fromAtom (DayAtom d) = d
8181 fromAtom _ = error "improper fromAtom"
8282 toAtomType _ = DayAtomType
83− toDatabaseContextExpr _ = NoOperation
83+ toAddTypeExpr _ = NoOperation
8484
8585instance Atomable UTCTime where
8686 toAtom = DateTimeAtom
8787 fromAtom (DateTimeAtom t) = t
8888 fromAtom _ = error "improper fromAtom"
8989 toAtomType _ = DateTimeAtomType
90− toDatabaseContextExpr _ = NoOperation
90+ toAddTypeExpr _ = NoOperation
9191
9292instance Atomable ByteString where
9393 toAtom = ByteStringAtom
9494 fromAtom (ByteStringAtom b) = b
9595 fromAtom _ = error "improper fromAtom"
9696 toAtomType _ = ByteStringAtomType
97− toDatabaseContextExpr _ = NoOperation
97+ toAddTypeExpr _ = NoOperation
9898
9999instance Atomable Bool where
100100 toAtom = BoolAtom
101101 fromAtom (BoolAtom b) = b
102102 fromAtom _ = error "improper fromAtom"
103103 toAtomType _ = BoolAtomType
104− toDatabaseContextExpr _ = NoOperation
104+ toAddTypeExpr _ = NoOperation
105105
106106instance Atomable Relation where
107107 toAtom = RelationAtom
@@ -109,7 +109,7 @@ instance Atomable Relation where
109109 fromAtom _ = error "improper fromAtom"
110110 --warning: cannot be used with undefined "Relation"
111111 toAtomType rel = RelationAtomType (attributes rel)
112− toDatabaseContextExpr _ = NoOperation
112+ toAddTypeExpr _ = NoOperation
113113
114114--convert to ADT list
115115instance Atomable a => Atomable [a] where
@@ -121,7 +121,7 @@ instance Atomable a => Atomable [a] where
121121 fromAtom _ = error "improper fromAtom [a]"
122122
123123 toAtomType _ = ConstructedAtomType "List" (M.singleton "a" (toAtomType (undefined :: a)))
124− toDatabaseContextExpr _ = NoOperation
124+ toAddTypeExpr _ = NoOperation
125125
126126-- Generics
127127class AtomableG g where
@@ -130,7 +130,7 @@ class AtomableG g where
130130 fromAtomG :: Atom -> [Atom] -> Maybe (g a)
131131 toAtomTypeG :: g a -> AtomType --overall ConstructedAtomType
132132 toAtomsG :: g a -> [Atom]
133− toDatabaseContextExprG :: g a -> AtomType -> DatabaseContextExpr
133+ toAddTypeExprG :: g a -> AtomType -> DatabaseContextExpr
134134 getConstructorsG :: g a -> [DataConstructorDef]
135135 getConstructorArgsG :: g a -> [DataConstructorDefArg]
136136
@@ -142,11 +142,11 @@ instance (Datatype c, AtomableG a) => AtomableG (M1 D c a) where
142142 toAtomTypeG _ = ConstructedAtomType (T.pack typeName) M.empty -- generics don't allow us to get the type constructor variables- alternatives?
143143 where
144144 typeName = datatypeName (undefined :: M1 D c a x)
145− toDatabaseContextExprG (M1 v) (ConstructedAtomType tcName _) = AddTypeConstructor tcDef dataConstructors
145+ toAddTypeExprG (M1 v) (ConstructedAtomType tcName _) = AddTypeConstructor tcDef dataConstructors
146146 where
147147 tcDef = ADTypeConstructorDef tcName []
148148 dataConstructors = getConstructorsG v
149− toDatabaseContextExprG _ _ = NoOperation
149+ toAddTypeExprG _ _ = NoOperation
150150 getConstructorsG (M1 v) = getConstructorsG v
151151 getConstructorArgsG = undefined
152152
@@ -166,7 +166,7 @@ instance (Constructor c, AtomableG a) => AtomableG (M1 C c a) where
166166 fromAtomG _ _ = error "unsupported generic traversal"
167167 toAtomsG = undefined
168168 toAtomTypeG = undefined
169− toDatabaseContextExprG = undefined
169+ toAddTypeExprG = undefined
170170 getConstructorsG (M1 v) = [DataConstructorDef (T.pack dName) dArgs]
171171 where
172172 dName = conName (undefined :: M1 C c a x)
@@ -179,7 +179,7 @@ instance (Selector c, AtomableG a) => AtomableG (M1 S c a) where
179179 fromAtomG atom args = M1 <$> fromAtomG atom args
180180 toAtomsG (M1 v) = toAtomsG v
181181 toAtomTypeG (M1 v) = toAtomTypeG v
182− toDatabaseContextExprG _ _ = undefined
182+ toAddTypeExprG _ _ = undefined
183183 getConstructorsG = undefined
184184 getConstructorArgsG (M1 v) = getConstructorArgsG v
185185
@@ -191,7 +191,7 @@ instance (Atomable a) => AtomableG (K1 c a) where
191191 headatom [] = error "no more atoms for constructor!"
192192 toAtomsG (K1 v) = [toAtom v]
193193 toAtomTypeG _ = toAtomType (undefined :: a)
194− toDatabaseContextExprG _ _ = undefined
194+ toAddTypeExprG _ _ = undefined
195195 getConstructorsG = undefined
196196 getConstructorArgsG (K1 v) = [DataConstructorDefTypeConstructorArg tCons]
197197 where
@@ -204,7 +204,7 @@ instance AtomableG U1 where
204204 fromAtomG _ _ = pure U1
205205 toAtomsG _ = []
206206 toAtomTypeG = undefined
207− toDatabaseContextExprG = undefined
207+ toAddTypeExprG = undefined
208208 getConstructorsG = undefined
209209 getConstructorArgsG _ = []
210210
@@ -218,7 +218,7 @@ instance (AtomableG a, AtomableG b) => AtomableG (a :*: b) where
218218 tailatoms [] = error "no more atoms in tail for product!"
219219 toAtomTypeG = undefined
220220 toAtomsG (x :*: y) = toAtomsG x ++ toAtomsG y
221− toDatabaseContextExprG _ _ = undefined
221+ toAddTypeExprG _ _ = undefined
222222 getConstructorsG = undefined
223223 getConstructorArgsG (x :*: y) = getConstructorArgsG x ++ getConstructorArgsG y
224224
@@ -230,7 +230,7 @@ instance (AtomableG a, AtomableG b) => AtomableG (a :+: b) where
230230 toAtomTypeG = undefined
231231 toAtomsG (L1 x) = toAtomsG x
232232 toAtomsG (R1 x) = toAtomsG x
233− toDatabaseContextExprG _ _ = undefined
233+ toAddTypeExprG _ _ = undefined
234234 getConstructorsG _ = getConstructorsG (undefined :: a x) ++ getConstructorsG (undefined :: b x)
235235 getConstructorArgsG = undefined
236236