packages feed

Logic (empty) → 0.1.0.0

raw patch · 5 files changed

+88/−0 lines, 5 filesdep +basesetup-changed

Dependencies added: base

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 gogotanaka++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Logic.cabal view
@@ -0,0 +1,23 @@+name:                Logic+version:             0.1.0.0+synopsis:            Logic+-- description:         +homepage:            http://gogotanaka.me/+license:             MIT+license-file:        LICENSE+author:              gogotanaka+maintainer:          mail@tanakakazuki.com+-- copyright:           +category:            Math+build-type:          Simple+extra-source-files:  README.md+cabal-version:       >=1.10++library+  exposed-modules:   Logic +  -- other-modules:       +  -- other-extensions:    +  build-depends:       base >=4.7 && <4.8+  hs-source-dirs:      src+  default-language:    Haskell2010+  
+ README.md view
@@ -0,0 +1,8 @@+# Logic
+
+    :l main.hs
+    p && q
+    p || q
+    p ==> q
+    p <=> q
+    (^) p
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Logic.hs view
@@ -0,0 +1,35 @@+module Logic where++import Prelude hiding ((^), (&&), (||))+import Data.List (intercalate)+data Logic = T | F | Atom String | Neg Logic | Or [Logic] | And [Logic]++instance Show Logic where+  show x = case x of+    Atom a -> a+    Neg p  -> "¬" ++ show p+    Or ps  -> intercalate " ∨ " (map show ps)+    And ps -> intercalate " ∧ " (map show ps)+    T      -> "T"+    F      -> "F"++p = Atom "p" :: Logic+q = Atom "q" :: Logic+r = Atom "r" :: Logic+++(^) :: Logic -> Logic+(^) p = Neg p++(||) :: Logic -> Logic -> Logic+(||) p q = Or [p, q]++(&&) :: Logic -> Logic -> Logic+(&&) p q = And [p, q]++(==>) :: Logic -> Logic -> Logic+(==>) p q = (Neg p) ||  q++(<=>) :: Logic -> Logic -> Logic+(<=>) p q = ((Neg p) || q) && (p || (Neg q))+