diff --git a/PureEqSat.cabal b/PureEqSat.cabal index 3236edd..32f191c 100644 --- a/PureEqSat.cabal +++ b/PureEqSat.cabal @@ -1,58 +1,26 @@ --- PureEqSat.cabal auto-generated by cabal init. For additional --- options, see --- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr. --- The name of the package. Name: PureEqSat - --- The package version. See the Haskell package versioning policy --- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for --- standards guiding when and how versions should be incremented. Version: 0.1 - --- A short (one-line) description of the package. --- Synopsis: Implementing equality saturation of a very small pure language - --- A longer description of the package. --- Description: - --- The license under which the package is released. License: MIT - --- The package author(s). Author: Daniel Gustafsson, Simon Edwardsson - --- An email address to which users can send suggestions, bug reports, --- and patches. --- Maintainer: - --- A copyright notice. --- Copyright: - Category: Language - Build-type: Simple - --- Extra files to be distributed with the package, such as examples or --- a README. --- Extra-source-files: - --- Constraint on the version of Cabal needed to build this package. Cabal-version: >=1.2 - Executable PureEqSat hs-source-dirs: src main-is: Main.hs - build-depends: base, parsec, containers, mtl, haskell98, cmdargs, QuickCheck >= 2.3 - -- .hs or .lhs file containing the Main module. - -- Main-is: - - -- Packages needed in order to build this package. - -- Build-depends: - - -- Modules not exported by this package. - -- Other-modules: - - -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source. - -- Build-tools: - + other-modules: Data.IOStableRef + Expr + IOSetA + Opt + Parser + Rule + TestExpr + Translate + + build-depends: base, + containers, + mtl, + cmdargs, + parsec, + QuickCheck diff --git a/README b/README deleted file mode 100644 index a58f2de..0000000 --- a/README +++ /dev/null @@ -1,24 +0,0 @@ -# Info about the project -This work has been done for the course Frontiers of Programming -Languages during the month of September in 2010. It presents a novel way -of doing optimizations in the style of equality saturation. This explores -the space of equivalent terms to and the best i.e. the optimized term. In -d to other approaches all terms will be saved and can be used to and new equivalent terms. - -# How to build -Make sure you have Haskell version 6.12 or newer. -Run the following commands -> cabal configure -> cabal build - -# How to use -To try an example program to optimize first build the project and then run -> ./dist/build/PureEqSat/PureEqSat -f examples/ex1.pes - -To see the various flags PureEqSat accepts run the program with --help - -WORD OF CAUTION: ex6.pes and ex7.pes are examples where the rule engine don't cut it. -Waiting for the results can lead to the end of the universe... - - - diff --git a/README.md b/README.md new file mode 100644 index 0000000..54ab6c8 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# Equality Saturation + +This work has been done for the course Frontiers of Programming +Languages during the month of September in 2010. It presents a novel way +of doing optimizations in the style of equality saturation. This explores +the space of equivalent terms to and the best i.e. the optimized term. In +d to other approaches all terms will be saved and can be used to and new equivalent terms. + +## How to build + +``` +stack setup +stack build +``` + +## How to use + +To try an example program to optimize first build the project and then run +``` +stack exec -- PureEqSat -f examples/ex1.pes +``` + +To see the various flags PureEqSat accepts run the program with --help + +**WORD OF CAUTION**: _ex6.pes_ and _ex7.pes_ are examples where the rule engine don't cut it. +Waiting for the results can lead to the end of the universe... + +## Examples + +``` +stack exec -- PureEqSat -f ex1.pes +From: 0 + x +To : x + +stack exec -- PureEqSat -f ex2.pes +From: x + y == y + x +To : True + +stack exec -- PureEqSat -f ex3.pes +From: if v then x * (a + b) else x * a + x * b +To : x * (a + b) + +stack exec -- PureEqSat -f ex4.pes +From: 45 * b + 19 * c + (12 * b + 15 * c) +To : b * 57 + c * 34 + +stack exec -- PureEqSat -f ex5.pes +From: x + y == z + x +To : y == z +``` diff --git a/src/Data/IOStableRef.hs b/src/Data/IOStableRef.hs index e7a51ba..82a39d2 100644 --- a/src/Data/IOStableRef.hs +++ b/src/Data/IOStableRef.hs @@ -1,12 +1,11 @@ module Data.IOStableRef - ( - IOStableRef, -- abstract, instance of: Eq, Ord, Typeable - newIOStableRef, -- :: a -> IO (IOStableRef a) - readIOStableRef, -- :: IOStableRef a -> IO a - writeIOStableRef, -- :: IOStableRef a -> a -> IO () - modifyIOStableRef, -- :: IOStableRef a -> (a -> a) -> IO () - hashIOStableRef, -- :: IOStableRef a -> Int - ) where + ( IOStableRef -- abstract, instance of: Eq, Ord, Typeable + , newIOStableRef -- :: a -> IO (IOStableRef a) + , readIOStableRef -- :: IOStableRef a -> IO a + , writeIOStableRef -- :: IOStableRef a -> a -> IO () + , modifyIOStableRef -- :: IOStableRef a -> (a -> a) -> IO () + , hashIOStableRef -- :: IOStableRef a -> Int + ) where import Prelude import Data.IORef diff --git a/src/IOSetA.hs b/src/IOSetA.hs index 0186a86..1ad8531 100644 --- a/src/IOSetA.hs +++ b/src/IOSetA.hs @@ -1,10 +1,9 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE PackageImports #-} module IOSetA where import Control.Monad -import "mtl" Control.Monad.State.Strict +import Control.Monad.State.Strict import Data.IOStableRef import Data.Maybe (listToMaybe) @@ -13,7 +12,7 @@ import Data.Set (Set) import Test.QuickCheck newtype IOSet s a = IS { runLS :: StateT (IState s) IO a } - deriving (MonadState (IState s), Monad, MonadIO, Functor) + deriving (MonadState (IState s), Monad, MonadIO, Applicative, Functor) data IState s = IState { classes :: [EqRepr s] -- Only pointers to Root elems! @@ -285,4 +284,4 @@ runTest = do quickCheck prop_union instance Testable b => Testable (IOSet a b) where - property b = property $ runEqClass b + property b = ioProperty $ runEqClass b diff --git a/src/Opt.hs b/src/Opt.hs index de1e953..86b90f1 100644 --- a/src/Opt.hs +++ b/src/Opt.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE PackageImports #-} module Opt ( OptMonad -- :: * -> * -> * , D.EqRepr -- :: * -> * @@ -22,7 +21,7 @@ module Opt import Data.Foldable (toList) import qualified IOSetA as D -- för att kunna ha samma namn fast lifted import Control.Monad -import "mtl" Control.Monad.State.Strict +import Control.Monad.State.Strict import qualified Data.Map as M import qualified Data.Set as S diff --git a/src/Rule.hs b/src/Rule.hs index 04bb741..306014c 100644 --- a/src/Rule.hs +++ b/src/Rule.hs @@ -1,5 +1,4 @@ {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE PackageImports #-} module Rule where import Expr @@ -9,7 +8,7 @@ import Debug.Trace import Data.Maybe import Data.List (groupBy,sort, sortBy) import Control.Monad -import "mtl" Control.Monad.Trans +import Control.Monad.Trans import Data.List (zipWith4) import Data.Either import Data.Function diff --git a/src/TestExpr.hs b/src/TestExpr.hs index 7b24b6c..ac796e3 100644 --- a/src/TestExpr.hs +++ b/src/TestExpr.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE PackageImports #-} {-# LANGUAGE TypeFamilies #-} module TestExpr where @@ -16,7 +15,7 @@ import Data.IORef import Data.IOStableRef import qualified Data.Set as S -import "mtl" Control.Monad.State +import Control.Monad.State import qualified Data.Map as M diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..d082516 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,3 @@ +resolver: lts-10.10 +packages: +- .