initial setup for NaiveDatabase
This commit is contained in:
parent
d31a01ab9c
commit
2900e781a1
26
haskell-experiments/LICENSE
Normal file
26
haskell-experiments/LICENSE
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
Copyright (c) 2025, Obsidian Systems
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
@ -81,12 +81,13 @@ test-suite haskell-exps-test
|
|||||||
other-modules: Test.OlogsSpec,
|
other-modules: Test.OlogsSpec,
|
||||||
Test.SimpleParserSpec,
|
Test.SimpleParserSpec,
|
||||||
Test.ArithmeticParserSpec,
|
Test.ArithmeticParserSpec,
|
||||||
Test.Datalog.DatalogParserSpec
|
Test.Datalog.DatalogParserSpec,
|
||||||
|
Test.Datalog.NaiveDatabaseSpec
|
||||||
|
|
||||||
library langfeatures
|
library langfeatures
|
||||||
build-depends: base, containers, megaparsec, parser-combinators, text
|
build-depends: base, containers, megaparsec, parser-combinators, text
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
exposed-modules: Ologs, SimpleParser, ArithmeticParser, Datalog.DatalogParser
|
exposed-modules: Ologs, SimpleParser, ArithmeticParser, Datalog.DatalogParser, Datalog.NaiveDatabase
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
executable haskell-experiments
|
executable haskell-experiments
|
||||||
|
|||||||
18
haskell-experiments/src/Datalog/NaiveDatabase.hs
Normal file
18
haskell-experiments/src/Datalog/NaiveDatabase.hs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||||
|
|
||||||
|
{-# HLINT ignore "Redundant flip" #-}
|
||||||
|
module Datalog.NaiveDatabase where
|
||||||
|
|
||||||
|
import Data.Map (Map)
|
||||||
|
import Data.Set (Set)
|
||||||
|
|
||||||
|
data Value =
|
||||||
|
ValueInt Int |
|
||||||
|
ValueSymbol String
|
||||||
|
|
||||||
|
data NaiveDatabase = NaiveDatabase {
|
||||||
|
relations :: Map String Int,
|
||||||
|
values :: Set Value
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ import qualified Test.OlogsSpec as Ologs
|
|||||||
import qualified Test.SimpleParserSpec as SimpleParserSpec
|
import qualified Test.SimpleParserSpec as SimpleParserSpec
|
||||||
import qualified Test.ArithmeticParserSpec as ArithmeticParserSpec
|
import qualified Test.ArithmeticParserSpec as ArithmeticParserSpec
|
||||||
import qualified Test.Datalog.DatalogParserSpec as DatalogParserSpec
|
import qualified Test.Datalog.DatalogParserSpec as DatalogParserSpec
|
||||||
|
import qualified Test.Datalog.NaiveDatabaseSpec as NaiveDatabaseSpec
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspec $ do
|
main = hspec $ do
|
||||||
@ -12,4 +13,5 @@ main = hspec $ do
|
|||||||
describe "SimpleParser" SimpleParserSpec.spec
|
describe "SimpleParser" SimpleParserSpec.spec
|
||||||
describe "ArithmeticParser" ArithmeticParserSpec.spec
|
describe "ArithmeticParser" ArithmeticParserSpec.spec
|
||||||
describe "DatalogParser" DatalogParserSpec.spec
|
describe "DatalogParser" DatalogParserSpec.spec
|
||||||
|
describe "NaiveDatabase" NaiveDatabaseSpec.spec
|
||||||
|
|
||||||
|
|||||||
@ -14,15 +14,6 @@ module Test.Datalog.DatalogParserSpec where
|
|||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Datalog.DatalogParser
|
import Datalog.DatalogParser
|
||||||
|
|
||||||
-- checkParse :: String -> Expr -> Expectation
|
|
||||||
-- checkParse text expectedExpr =
|
|
||||||
-- parse parseExpr "" text `shouldBe` Right expectedExpr
|
|
||||||
|
|
||||||
-- checkEval :: String -> Int -> Expectation
|
|
||||||
-- checkEval text expectedVal =
|
|
||||||
-- fmap eval (parse parseExpr "" text) `shouldBe` Right expectedVal
|
|
||||||
|
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "evaluate expressions" $ do
|
describe "evaluate expressions" $ do
|
||||||
|
|||||||
30
haskell-experiments/test/Test/Datalog/NaiveDatabaseSpec.hs
Normal file
30
haskell-experiments/test/Test/Datalog/NaiveDatabaseSpec.hs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE DuplicateRecordFields #-}
|
||||||
|
{-# LANGUAGE OverloadedRecordDot #-}
|
||||||
|
{-# HLINT ignore "Use const" #-}
|
||||||
|
{-# HLINT ignore "Unused LANGUAGE pragma" #-}
|
||||||
|
{-# HLINT ignore "Avoid lambda" #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# LANGUAGE NoFieldSelectors #-}
|
||||||
|
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
|
||||||
|
module Test.Datalog.NaiveDatabaseSpec where
|
||||||
|
|
||||||
|
import Test.Hspec
|
||||||
|
import Datalog.NaiveDatabase
|
||||||
|
|
||||||
|
-- checkParse :: String -> Expr -> Expectation
|
||||||
|
-- checkParse text expectedExpr =
|
||||||
|
-- parse parseExpr "" text `shouldBe` Right expectedExpr
|
||||||
|
|
||||||
|
-- checkEval :: String -> Int -> Expectation
|
||||||
|
-- checkEval text expectedVal =
|
||||||
|
-- fmap eval (parse parseExpr "" text) `shouldBe` Right expectedVal
|
||||||
|
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = do
|
||||||
|
describe "dummy test" $ do
|
||||||
|
it "..." $ do
|
||||||
|
1 `shouldBe` (1 :: Int)
|
||||||
Loading…
x
Reference in New Issue
Block a user