basic API for query engines

This commit is contained in:
Felix Dilke 2026-01-30 18:29:12 +00:00
parent 697568a8c3
commit 0b98490756
2 changed files with 35 additions and 0 deletions

View File

@ -4,5 +4,32 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# LANGUAGE BlockArguments #-}
{-# HLINT ignore "Redundant flip" #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE BlockArguments #-}
module Datalog.NaiveQE where
import Datalog.QueryEngine
import Data.Text
import Datalog.DatalogDB
import Datalog.DatalogParser
import Control.Exception
data NaiveQE = NaiveQE
{
} deriving (Show, Eq)
instance QueryEngine NaiveQE where
queryEngine :: (DatalogDB db) => db -> NaiveQE
queryEngine db = NaiveQE { }
query :: NaiveQE -> Text -> Text
query qe queryText =
case parseDatalog queryText of
Right (Query texts literals) -> "#NYI"
Right otherStatement -> throw $ NonQueryException queryText otherStatement
Left ex -> throw $ CannotParseStatementException queryText ex

View File

@ -6,3 +6,11 @@
{-# LANGUAGE BlockArguments #-}
module Datalog.QueryEngine where
import Datalog.DatalogDB
import Data.Text
class QueryEngine qe where
queryEngine :: (DatalogDB db) => db -> qe
query :: qe -> Text -> Text