@@ -8,8 +8,11 @@ module Database.Bolt.Extras.Internal.Types
88 , Property
99 , ToValue (.. )
1010 , URelationLike (.. )
11+ , ToIsValue (.. )
12+ , NodeLikeProps (.. )
1113 ) where
1214
15+ import GHC.Stack (HasCallStack )
1316import Data.Map.Strict (Map )
1417import Data.Text (Text )
1518import Database.Bolt (Node (.. ), URelationship (.. ), Value (.. ))
@@ -25,29 +28,29 @@ type Property = (Text, Value)
2528-- | 'NodeLike' class represents convertable into and from 'Node'.
2629--
2730class NodeLike a where
28- toNode :: a -> Node
29- fromNode :: Node -> a
31+ toNode :: HasCallStack => a -> Node
32+ fromNode :: HasCallStack => Node -> a
3033
3134-- | 'URelationLike' class represents convertable into and from 'URelationship'.
3235--
3336class URelationLike a where
34- toURelation :: a -> URelationship
35- fromURelation :: URelationship -> a
37+ toURelation :: HasCallStack => a -> URelationship
38+ fromURelation :: HasCallStack => URelationship -> a
3639
3740-- | 'ToValue' means that something can be converted into Bolt 'Value'.
3841--
3942class ToValue a where
40- toValue :: a -> Value
43+ toValue :: HasCallStack => a -> Value
4144
4245-- | 'FromValue' means that something can be converted from Bolt 'Value'.
4346--
4447class FromValue a where
45- fromValue :: Value -> a
48+ fromValue :: HasCallStack => Value -> a
4649
4750-- | 'Labels' means that labels can be obtained from entity.
4851--
4952class Labels a where
50- getLabels :: a -> [Label ]
53+ getLabels :: HasCallStack => a -> [Label ]
5154
5255instance Labels Node where
5356 getLabels = labels
@@ -58,10 +61,16 @@ instance Labels URelationship where
5861-- | 'Properties' means that properties can be obtained from entity.
5962--
6063class Properties a where
61- getProps :: a -> Map Text Value
64+ getProps :: HasCallStack => a -> Map Text Value
6265
6366instance Properties Node where
6467 getProps = nodeProps
6568
6669instance Properties URelationship where
6770 getProps = urelProps
71+
72+ -- | ToIsValue provides IsValue instance given ToValue
73+ newtype ToIsValue a = ToIsValue a
74+
75+ -- | NodeLikeProps provides IsValue instance given NodeLike, in form of Map Text Value
76+ newtype NodeLikeProps a = NodeLikeProps a
0 commit comments