basic API for query engines
This commit is contained in:
parent
697568a8c3
commit
0b98490756
@ -4,5 +4,32 @@
|
|||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||||
{-# LANGUAGE BlockArguments #-}
|
{-# LANGUAGE BlockArguments #-}
|
||||||
|
{-# HLINT ignore "Redundant flip" #-}
|
||||||
|
{-# LANGUAGE ImportQualifiedPost #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||||
|
{-# LANGUAGE InstanceSigs #-}
|
||||||
|
{-# LANGUAGE BlockArguments #-}
|
||||||
|
|
||||||
module Datalog.NaiveQE where
|
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
|
||||||
|
|
||||||
|
|||||||
@ -6,3 +6,11 @@
|
|||||||
{-# LANGUAGE BlockArguments #-}
|
{-# LANGUAGE BlockArguments #-}
|
||||||
|
|
||||||
module Datalog.QueryEngine where
|
module Datalog.QueryEngine where
|
||||||
|
import Datalog.DatalogDB
|
||||||
|
import Data.Text
|
||||||
|
|
||||||
|
class QueryEngine qe where
|
||||||
|
queryEngine :: (DatalogDB db) => db -> qe
|
||||||
|
query :: qe -> Text -> Text
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user