on master help sign in
switch to lowercase proxy where possible

3noch believes this will allow for looser Proxy types

commit5b1fe0fbbe4b1061665383a63cf2049f7b186dee authorAgentM <agentm@themactionfaction.com> dateThu 5 Oct 2017, 17:12 (9 years ago) parent8fbcf59
3 files changed+9−11
docs/tupleable.markdown+1−1 src/lib/ProjectM36/Atomable.hs+4−4 src/lib/ProjectM36/Tupleable.hs+4−6
docs/tupleable.markdown+1−1
@@ -29,7 +29,7 @@ The ```Tupleable``` module includes the following functions:
2929
3030 * ```toInsertExpr :: forall a t. (Tupleable a, Traversable t) => t a -> RelVarName -> Either RelationalError DatabaseContextExpr```
3131 * creates an ```Insert``` expression which can be used to insert a set of ```Tupleable``` values into the relation variable named by the ```RelVarName```
32− * ```toAttributes :: Proxy a -> Attributes```
32+ * ```toAttributes :: proxy a -> Attributes```
3333 * generates ```Attributes``` from a ```Tupleable``` value- can be used with ```undefined```, so an actual value is not necessary
3434 * ```toTuple :: a -> RelationTuple```
3535 * converts a ```Tupleable``` value to a tuple for use in queries
src/lib/ProjectM36/Atomable.hs+4−4
@@ -47,14 +47,14 @@ class (Eq a, NFData a, Binary a, Show a) => Atomable a where
4747 Nothing -> error "no fromAtomG for Atom found"
4848 Just x -> to x
4949
50− toAtomType :: Proxy a -> AtomType
51− default toAtomType :: (Generic a, AtomableG (Rep a)) => Proxy a -> AtomType
50+ toAtomType :: proxy a -> AtomType
51+ default toAtomType :: (Generic a, AtomableG (Rep a)) => proxy a -> AtomType
5252 toAtomType _ = toAtomTypeG (from (undefined :: a))
5353
5454 -- | Creates DatabaseContextExpr necessary to load the type constructor and data constructor into the database.
5555 toAddTypeExpr :: Proxy a -> DatabaseContextExpr
56− default toAddTypeExpr :: (Generic a, AtomableG (Rep a)) => Proxy a -> DatabaseContextExpr
57− toAddTypeExpr p = toAddTypeExprG (from (undefined ::a)) (toAtomType p)
56+ default toAddTypeExpr :: (Generic a, AtomableG (Rep a)) => proxy a -> DatabaseContextExpr
57+ toAddTypeExpr _ = toAddTypeExprG (from (undefined :: a)) (toAtomType (Proxy :: Proxy a))
5858
5959instance Atomable Integer where
6060 toAtom = IntegerAtom
src/lib/ProjectM36/Tupleable.hs+4−6
@@ -57,18 +57,16 @@ toInsertExpr vals rvName = do
5757
5858-- | Convert a 'Tupleable' to a create a 'Define' expression which can be used to create an empty relation variable. Use 'toInsertExpr' to insert the actual tuple data. This function is typically used with 'Data.Proxy'.
5959toDefineExpr :: Tupleable a => Proxy a -> RelVarName -> DatabaseContextExpr
60−toDefineExpr val rvName = Define rvName (map NakedAttributeExpr (V.toList attrs))
60+toDefineExpr prox rvName = Define rvName (map NakedAttributeExpr (V.toList attrs))
6161 where
62− attrs = toAttributes val
63−
64−
62+ attrs = toAttributes prox
6563
6664class Tupleable a where
6765 toTuple :: a -> RelationTuple
6866
6967 fromTuple :: RelationTuple -> Either RelationalError a
7068
71− toAttributes :: Proxy a -> Attributes
69+ toAttributes :: proxy a -> Attributes
7270
7371 default toTuple :: (Generic a, TupleableG (Rep a)) => a -> RelationTuple
7472 toTuple v = toTupleG (from v)
@@ -76,7 +74,7 @@ class Tupleable a where
7674 default fromTuple :: (Generic a, TupleableG (Rep a)) => RelationTuple -> Either RelationalError a
7775 fromTuple tup = to <$> fromTupleG tup
7876
79− default toAttributes :: (Generic a, TupleableG (Rep a)) => Proxy a -> Attributes
77+ default toAttributes :: (Generic a, TupleableG (Rep a)) => proxy a -> Attributes
8078 toAttributes _ = toAttributesG (from (undefined :: a))
8179
8280class TupleableG g where