diff --git a/haskell-experiments/src/Datalog/NaiveDatabase.hs b/haskell-experiments/src/Datalog/NaiveDatabase.hs index 1727fe1..81e62ae 100644 --- a/haskell-experiments/src/Datalog/NaiveDatabase.hs +++ b/haskell-experiments/src/Datalog/NaiveDatabase.hs @@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} +{-# LANGUAGE InstanceSigs #-} module Datalog.NaiveDatabase where @@ -25,13 +26,18 @@ data NaiveDatabase = NaiveDatabase } deriving (Show, Eq) -emptyDB :: NaiveDatabase -emptyDB = - NaiveDatabase +instance DatalogDB NaiveDatabase where + emptyDB :: NaiveDatabase + emptyDB = NaiveDatabase { relations = Map.empty , constants = Set.empty -- the Herbrand universe } + -- lookupRelation :: NaiveDatabase -> Text -> Maybe Relation -> NaiveDatabase + -- lookupRelation = _ + -- insertRelation :: NaiveDatabase -> Text -> Relation -> NaiveDatabase + -- insertRelation = _ + lookupRelation :: RelationId -> Map RelationId Relation -> Int -> Set [Term] -> Relation lookupRelation relationName relationMap newArity tuples = case Map.lookup relationName relationMap of diff --git a/haskell-experiments/src/Datalog/Rules.hs b/haskell-experiments/src/Datalog/Rules.hs index 20a5c9e..a0b1f8f 100644 --- a/haskell-experiments/src/Datalog/Rules.hs +++ b/haskell-experiments/src/Datalog/Rules.hs @@ -46,3 +46,8 @@ data Relation = Relation -- Our constants will be the terms of the Datalog grammar - ints/variables/symbols type Constant = Term type RelationId = Text + +class DatalogDB db where + emptyDB :: db + -- lookupRelation :: db -> Text -> Maybe Relation -> db + -- insertRelation :: db -> Text -> Relation -> db