module Database.Bolt.Extras.Utils
(
dummyId
, union
, currentLoc
) where
import Data.List (nub)
import qualified Data.Map.Strict as M (union)
import Database.Bolt (Node (..))
import Language.Haskell.TH (Exp (..), Lit (..), Loc (..), Q, location)
import Text.Printf (printf)
dummyId :: Int
dummyId = -1
union :: Node -> Node -> Node
(Node _ labels1 props1) `union` (Node _ labels2 props2) = Node dummyId
(nub $ labels1 ++ labels2)
(props1 `M.union` props2)
currentLoc :: Q Exp
currentLoc = do
loc <- location
pure $ LitE $ StringL $ printf "%s:%d: " (loc_module loc) (fst $ loc_start loc)