introduce typeclass

This commit is contained in:
Felix Dilke 2026-01-29 16:42:53 +00:00
parent 0a1a39cfc9
commit fe899bbb0c
2 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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