From dff5b9f36550a6c6445b8f206fa9a3db135f77a8 Mon Sep 17 00:00:00 2001 From: hi Date: Fri, 15 Aug 2025 13:10:36 +0000 Subject: [PATCH] cabal only doing this because Data.Set is not in the stdlib --- .gitignore | 4 ++ Makefile | 12 +++-- changelog.md | 3 ++ {Logic => lib/Logic}/Graph.hs | 0 {Logic => lib/Logic}/Language.hs | 0 {Logic => lib/Logic}/Language/Derivation.hs | 0 {Logic => lib/Logic}/Language/Impl/L.hs | 6 +-- {Logic => lib/Logic}/Language/Impl/MIU.hs | 3 +- {Logic => lib/Logic}/Parse.hs | 7 ++- {Logic => lib/Logic}/Statement.hs | 0 {Logic => lib/Logic}/Statement/Eval.hs | 3 +- {Logic => lib/Logic}/Statement/Laws.hs | 0 {Logic => lib/Logic}/Statement/Parse.hs | 5 +- {Logic => lib/Logic}/Statement/Serialize.hs | 0 {Logic => lib/Logic}/readme.md | 0 logic.cabal | 56 +++++++++++++++++++++ readme.md | 14 +++++- Main.hs => src/Main.hs | 0 test/Main.hs | 4 ++ 19 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 changelog.md rename {Logic => lib/Logic}/Graph.hs (100%) rename {Logic => lib/Logic}/Language.hs (100%) rename {Logic => lib/Logic}/Language/Derivation.hs (100%) rename {Logic => lib/Logic}/Language/Impl/L.hs (98%) rename {Logic => lib/Logic}/Language/Impl/MIU.hs (95%) rename {Logic => lib/Logic}/Parse.hs (94%) rename {Logic => lib/Logic}/Statement.hs (100%) rename {Logic => lib/Logic}/Statement/Eval.hs (97%) rename {Logic => lib/Logic}/Statement/Laws.hs (100%) rename {Logic => lib/Logic}/Statement/Parse.hs (96%) rename {Logic => lib/Logic}/Statement/Serialize.hs (100%) rename {Logic => lib/Logic}/readme.md (100%) create mode 100644 logic.cabal rename Main.hs => src/Main.hs (100%) create mode 100644 test/Main.hs diff --git a/.gitignore b/.gitignore index 1d0658a..77f6ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ # special cases !Makefile + +# cabal +.cabal-build/ +dist-newstyle/ diff --git a/Makefile b/Makefile index 88d6e77..9cd2424 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ -main: dirty clean +main: ghc-dirty clean -dirty: - ghc Main.hs -o logic +ghc-dirty: + cd lib; ghc ../src/Main.hs -o ../logic clean: - find | grep -E '\.(hi|o)$$' | xargs rm -- + find src lib test | grep -E '\.(hi|o)$$' | xargs rm -- + +cabal: + cabal build --builddir=.cabal-build + mv .cabal-build/build/*/*/logic-*/x/logic/build/logic/logic . diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..8477187 --- /dev/null +++ b/changelog.md @@ -0,0 +1,3 @@ +## 0.0.0 + +TODO diff --git a/Logic/Graph.hs b/lib/Logic/Graph.hs similarity index 100% rename from Logic/Graph.hs rename to lib/Logic/Graph.hs diff --git a/Logic/Language.hs b/lib/Logic/Language.hs similarity index 100% rename from Logic/Language.hs rename to lib/Logic/Language.hs diff --git a/Logic/Language/Derivation.hs b/lib/Logic/Language/Derivation.hs similarity index 100% rename from Logic/Language/Derivation.hs rename to lib/Logic/Language/Derivation.hs diff --git a/Logic/Language/Impl/L.hs b/lib/Logic/Language/Impl/L.hs similarity index 98% rename from Logic/Language/Impl/L.hs rename to lib/Logic/Language/Impl/L.hs index ba329fd..897d3ac 100644 --- a/Logic/Language/Impl/L.hs +++ b/lib/Logic/Language/Impl/L.hs @@ -125,11 +125,11 @@ parseL = Parser variable <|> Parser tilde <|> arrow <|> fail arrow :: Parser AlphaL Statement arrow = do - parseToken [Open] + _ <- parseToken [Open] s1 <- parseL - parseToken [Arrow] + _ <- parseToken [Arrow] s2 <- parseL - parseToken [Close] + _ <- parseToken [Close] return $ Implies s1 s2 fail :: Parser AlphaL Statement diff --git a/Logic/Language/Impl/MIU.hs b/lib/Logic/Language/Impl/MIU.hs similarity index 95% rename from Logic/Language/Impl/MIU.hs rename to lib/Logic/Language/Impl/MIU.hs index 70f056f..a7ce544 100644 --- a/Logic/Language/Impl/MIU.hs +++ b/lib/Logic/Language/Impl/MIU.hs @@ -1,6 +1,6 @@ module Logic.Language.Impl.MIU where -import Logic.Language (Language(..), ConcatShowList(..)) +import Logic.Language (Language(..)) import Logic.Language.Derivation (Derivation(..)) -- The MIU system @@ -56,6 +56,7 @@ miuRule4 string@(M:xs) = (M:) <$> aux xs miuRule4 _ = [] {- +ghci> import Logic.Language (ConcatShowList(..)) ghci> map ConcatShowList infer0 :: [ConcatShowList AlphaMIU] [MI] ghci> map ConcatShowList $ concat $ map ($ [M, I, I, I, I, U, U, I]) infer1 diff --git a/Logic/Parse.hs b/lib/Logic/Parse.hs similarity index 94% rename from Logic/Parse.hs rename to lib/Logic/Parse.hs index b98744f..ada6a68 100644 --- a/Logic/Parse.hs +++ b/lib/Logic/Parse.hs @@ -1,7 +1,10 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE TupleSections #-} + module Logic.Parse where -import Control.Applicative (Applicative, Alternative(..)) -import Data.Functor (Functor) +import Control.Applicative (Alternative(..)) newtype Parser symbol output = Parser { runParser :: Input symbol -> Either ParseError (output, Input symbol) diff --git a/Logic/Statement.hs b/lib/Logic/Statement.hs similarity index 100% rename from Logic/Statement.hs rename to lib/Logic/Statement.hs diff --git a/Logic/Statement/Eval.hs b/lib/Logic/Statement/Eval.hs similarity index 97% rename from Logic/Statement/Eval.hs rename to lib/Logic/Statement/Eval.hs index 83d716c..6c96d29 100644 --- a/Logic/Statement/Eval.hs +++ b/lib/Logic/Statement/Eval.hs @@ -1,8 +1,9 @@ +{-# LANGUAGE TupleSections #-} + module Logic.Statement.Eval where import Logic.Statement (Statement(..), atoms) -import Data.List (intercalate) import Data.Either (fromRight) data Bucket diff --git a/Logic/Statement/Laws.hs b/lib/Logic/Statement/Laws.hs similarity index 100% rename from Logic/Statement/Laws.hs rename to lib/Logic/Statement/Laws.hs diff --git a/Logic/Statement/Parse.hs b/lib/Logic/Statement/Parse.hs similarity index 96% rename from Logic/Statement/Parse.hs rename to lib/Logic/Statement/Parse.hs index f0c9e48..8aac6fe 100644 --- a/Logic/Statement/Parse.hs +++ b/lib/Logic/Statement/Parse.hs @@ -3,7 +3,6 @@ module Logic.Statement.Parse where import Logic.Parse ( Parser(..) , Input(..) - , ParseError , expected , parseToken , parseIf @@ -23,11 +22,11 @@ stmtNot = Not <$> (parseToken "!" *> stmt) stmtBinary :: Parser Char Statement stmtBinary = do - parseToken "(" + _ <- parseToken "(" s1 <- stmt constructor <- parseConnective s2 <- stmt - parseToken ")" + _ <- parseToken ")" return $ constructor s1 s2 where parseConnective = diff --git a/Logic/Statement/Serialize.hs b/lib/Logic/Statement/Serialize.hs similarity index 100% rename from Logic/Statement/Serialize.hs rename to lib/Logic/Statement/Serialize.hs diff --git a/Logic/readme.md b/lib/Logic/readme.md similarity index 100% rename from Logic/readme.md rename to lib/Logic/readme.md diff --git a/logic.cabal b/logic.cabal new file mode 100644 index 0000000..7904d07 --- /dev/null +++ b/logic.cabal @@ -0,0 +1,56 @@ +cabal-version: 3.4 +name: logic +version: 0.0.0 +homepage: https://git.atomic.garden/root/logic +license: NONE +category: Math +build-type: Simple +extra-doc-files: + changelog.md + readme.md + lib/Logic/readme.md + +common warnings + ghc-options: -Wall + +library + import: warnings + exposed-modules: + Logic.Graph + Logic.Language + Logic.Language.Derivation + Logic.Language.Impl.L + Logic.Language.Impl.MIU + Logic.Parse + Logic.Statement + Logic.Statement.Eval + Logic.Statement.Laws + Logic.Statement.Parse + Logic.Statement.Serialize + + build-depends: + base ^>=4.17.2.1, + containers ^>=0.6.7, + + hs-source-dirs: lib + default-language: Haskell2010 + +executable logic + import: warnings + main-is: Main.hs + build-depends: + base ^>=4.17.2.1, + logic, + + hs-source-dirs: src + default-language: Haskell2010 + +test-suite logic-test + import: warnings + default-language: Haskell2010 + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Main.hs + build-depends: + base ^>=4.17.2.1, + logic, diff --git a/readme.md b/readme.md index 9e5b23f..9364ba0 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,9 @@ see [Logic/readme.md](Logic) for more details about what's here ## requirements -a haskell compiler e.g. GHC +- a haskell compiler e.g. GHC +- cabal the haskell build system if you want +- [containers](https://hackage.haskell.org/package/containers) ## compile it @@ -14,9 +16,17 @@ make or look in [`Makefile`](Makefile) +or + +```sh +cabal build +``` + +I guess... + ## usage -only this has been implemented in the main function: +only this kind of this has been implemented in the main function so far: ```sh echo '((p->q)<->(!q->!p))' | ./logic diff --git a/Main.hs b/src/Main.hs similarity index 100% rename from Main.hs rename to src/Main.hs diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 0000000..3e2059e --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = putStrLn "Test suite not yet implemented."