-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
talos: fixed up Case (Patterns) for muxvalue
- Loading branch information
1 parent
b0b5370
commit d5011e4
Showing
9 changed files
with
327 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
-- Functions which should be in other libraries but aren't | ||
|
||
module Talos.Lib where | ||
|
||
import qualified SimpleSMT as S | ||
import SimpleSMT (SExpr) | ||
import Data.Foldable (toList) | ||
|
||
-- ----------------------------------------------------------------------------- | ||
-- base | ||
|
||
-- short-circuiting | ||
andM :: Monad m => [m Bool] -> m Bool | ||
andM [] = pure True | ||
andM (m : ms) = do | ||
b <- m | ||
if b then andM ms else pure False | ||
|
||
orM :: Monad m => [m Bool] -> m Bool | ||
orM [] = pure False | ||
orM (m : ms) = do | ||
b <- m | ||
if b then pure True else orM ms | ||
|
||
findM :: (Foldable t, Monad m) => (a -> m Bool) -> t a -> m (Maybe a) | ||
findM f = go . toList | ||
where | ||
go [] = pure Nothing | ||
go (x : xs) = do | ||
b <- f x | ||
if b then pure (Just x) else findM f xs | ||
|
||
-- ----------------------------------------------------------------------------- | ||
-- simple-smt | ||
|
||
orMany :: [SExpr] -> SExpr | ||
orMany [x] = x | ||
orMany xs = S.orMany xs | ||
|
||
andMany :: [SExpr] -> SExpr | ||
andMany [x] = x | ||
andMany xs = S.andMany xs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.