introduce typeclass
This commit is contained in:
parent
0a1a39cfc9
commit
fe899bbb0c
@ -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)
|
||||
|
||||
|
||||
instance DatalogDB NaiveDatabase where
|
||||
emptyDB :: NaiveDatabase
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user