diff --git a/haskell-experiments/LICENSE b/haskell-experiments/LICENSE new file mode 100644 index 0000000..55b0a06 --- /dev/null +++ b/haskell-experiments/LICENSE @@ -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. diff --git a/haskell-experiments/haskell-experiments.cabal b/haskell-experiments/haskell-experiments.cabal index ee51e5d..fbd49d1 100644 --- a/haskell-experiments/haskell-experiments.cabal +++ b/haskell-experiments/haskell-experiments.cabal @@ -81,12 +81,13 @@ test-suite haskell-exps-test other-modules: Test.OlogsSpec, Test.SimpleParserSpec, Test.ArithmeticParserSpec, - Test.Datalog.DatalogParserSpec + Test.Datalog.DatalogParserSpec, + Test.Datalog.NaiveDatabaseSpec library langfeatures build-depends: base, containers, megaparsec, parser-combinators, text hs-source-dirs: src - exposed-modules: Ologs, SimpleParser, ArithmeticParser, Datalog.DatalogParser + exposed-modules: Ologs, SimpleParser, ArithmeticParser, Datalog.DatalogParser, Datalog.NaiveDatabase ghc-options: -Wall executable haskell-experiments diff --git a/haskell-experiments/src/Datalog/NaiveDatabase.hs b/haskell-experiments/src/Datalog/NaiveDatabase.hs new file mode 100644 index 0000000..6b16444 --- /dev/null +++ b/haskell-experiments/src/Datalog/NaiveDatabase.hs @@ -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 +} \ No newline at end of file diff --git a/haskell-experiments/test/Main.hs b/haskell-experiments/test/Main.hs index 5013d96..6893b71 100644 --- a/haskell-experiments/test/Main.hs +++ b/haskell-experiments/test/Main.hs @@ -5,6 +5,7 @@ import qualified Test.OlogsSpec as Ologs import qualified Test.SimpleParserSpec as SimpleParserSpec import qualified Test.ArithmeticParserSpec as ArithmeticParserSpec import qualified Test.Datalog.DatalogParserSpec as DatalogParserSpec +import qualified Test.Datalog.NaiveDatabaseSpec as NaiveDatabaseSpec main :: IO () main = hspec $ do @@ -12,4 +13,5 @@ main = hspec $ do describe "SimpleParser" SimpleParserSpec.spec describe "ArithmeticParser" ArithmeticParserSpec.spec describe "DatalogParser" DatalogParserSpec.spec + describe "NaiveDatabase" NaiveDatabaseSpec.spec diff --git a/haskell-experiments/test/Test/Datalog/DatalogParserSpec.hs b/haskell-experiments/test/Test/Datalog/DatalogParserSpec.hs index 8048325..25f9bc6 100644 --- a/haskell-experiments/test/Test/Datalog/DatalogParserSpec.hs +++ b/haskell-experiments/test/Test/Datalog/DatalogParserSpec.hs @@ -14,15 +14,6 @@ module Test.Datalog.DatalogParserSpec where import Test.Hspec 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 = do describe "evaluate expressions" $ do diff --git a/haskell-experiments/test/Test/Datalog/NaiveDatabaseSpec.hs b/haskell-experiments/test/Test/Datalog/NaiveDatabaseSpec.hs new file mode 100644 index 0000000..0d1279b --- /dev/null +++ b/haskell-experiments/test/Test/Datalog/NaiveDatabaseSpec.hs @@ -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)