only doing this because Data.Set is not in the stdlib
This commit is contained in:
hi 2025-08-15 13:10:36 +00:00
parent 30941456a2
commit dff5b9f365
19 changed files with 101 additions and 16 deletions

4
.gitignore vendored
View file

@ -17,3 +17,7 @@
# special cases # special cases
!Makefile !Makefile
# cabal
.cabal-build/
dist-newstyle/

View file

@ -1,7 +1,11 @@
main: dirty clean main: ghc-dirty clean
dirty: ghc-dirty:
ghc Main.hs -o logic cd lib; ghc ../src/Main.hs -o ../logic
clean: 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 .

3
changelog.md Normal file
View file

@ -0,0 +1,3 @@
## 0.0.0
TODO

View file

@ -125,11 +125,11 @@ parseL = Parser variable <|> Parser tilde <|> arrow <|> fail
arrow :: Parser AlphaL Statement arrow :: Parser AlphaL Statement
arrow = do arrow = do
parseToken [Open] _ <- parseToken [Open]
s1 <- parseL s1 <- parseL
parseToken [Arrow] _ <- parseToken [Arrow]
s2 <- parseL s2 <- parseL
parseToken [Close] _ <- parseToken [Close]
return $ Implies s1 s2 return $ Implies s1 s2
fail :: Parser AlphaL Statement fail :: Parser AlphaL Statement

View file

@ -1,6 +1,6 @@
module Logic.Language.Impl.MIU where module Logic.Language.Impl.MIU where
import Logic.Language (Language(..), ConcatShowList(..)) import Logic.Language (Language(..))
import Logic.Language.Derivation (Derivation(..)) import Logic.Language.Derivation (Derivation(..))
-- The MIU system -- The MIU system
@ -56,6 +56,7 @@ miuRule4 string@(M:xs) = (M:) <$> aux xs
miuRule4 _ = [] miuRule4 _ = []
{- {-
ghci> import Logic.Language (ConcatShowList(..))
ghci> map ConcatShowList infer0 :: [ConcatShowList AlphaMIU] ghci> map ConcatShowList infer0 :: [ConcatShowList AlphaMIU]
[MI] [MI]
ghci> map ConcatShowList $ concat $ map ($ [M, I, I, I, I, U, U, I]) infer1 ghci> map ConcatShowList $ concat $ map ($ [M, I, I, I, I, U, U, I]) infer1

View file

@ -1,7 +1,10 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE TupleSections #-}
module Logic.Parse where module Logic.Parse where
import Control.Applicative (Applicative, Alternative(..)) import Control.Applicative (Alternative(..))
import Data.Functor (Functor)
newtype Parser symbol output = Parser newtype Parser symbol output = Parser
{ runParser :: Input symbol -> Either ParseError (output, Input symbol) { runParser :: Input symbol -> Either ParseError (output, Input symbol)

View file

@ -1,8 +1,9 @@
{-# LANGUAGE TupleSections #-}
module Logic.Statement.Eval where module Logic.Statement.Eval where
import Logic.Statement (Statement(..), atoms) import Logic.Statement (Statement(..), atoms)
import Data.List (intercalate)
import Data.Either (fromRight) import Data.Either (fromRight)
data Bucket data Bucket

View file

@ -3,7 +3,6 @@ module Logic.Statement.Parse where
import Logic.Parse import Logic.Parse
( Parser(..) ( Parser(..)
, Input(..) , Input(..)
, ParseError
, expected , expected
, parseToken , parseToken
, parseIf , parseIf
@ -23,11 +22,11 @@ stmtNot = Not <$> (parseToken "!" *> stmt)
stmtBinary :: Parser Char Statement stmtBinary :: Parser Char Statement
stmtBinary = do stmtBinary = do
parseToken "(" _ <- parseToken "("
s1 <- stmt s1 <- stmt
constructor <- parseConnective constructor <- parseConnective
s2 <- stmt s2 <- stmt
parseToken ")" _ <- parseToken ")"
return $ constructor s1 s2 return $ constructor s1 s2
where where
parseConnective = parseConnective =

56
logic.cabal Normal file
View file

@ -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,

View file

@ -4,7 +4,9 @@ see [Logic/readme.md](Logic) for more details about what's here
## requirements ## 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 ## compile it
@ -14,9 +16,17 @@ make
or look in [`Makefile`](Makefile) or look in [`Makefile`](Makefile)
or
```sh
cabal build
```
I guess...
## usage ## 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 ```sh
echo '((p->q)<->(!q->!p))' | ./logic echo '((p->q)<->(!q->!p))' | ./logic

4
test/Main.hs Normal file
View file

@ -0,0 +1,4 @@
module Main (main) where
main :: IO ()
main = putStrLn "Test suite not yet implemented."