Skip to content

Commit

Permalink
✨ Add mrgRunFreshT, resolving #109
Browse files Browse the repository at this point in the history
  • Loading branch information
lsrcz committed Oct 5, 2023
1 parent 32a0fea commit 2bc901a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added wrappers for state transformers. ([#132](https://github.com/lsrcz/grisette/pull/132))
- Added `toGuardList` function. ([#137](https://github.com/lsrcz/grisette/pull/137))
- Exported some previously hidden API (`BVSignConversion`, `runFreshTFromIndex`) that we found useful or forgot to export. ([#138](https://github.com/lsrcz/grisette/pull/138), [#139](https://github.com/lsrcz/grisette/pull/139))
- Provided `mrgRunFreshT` to run `FreshT` with merging. ([#140](https://github.com/lsrcz/grisette/pull/140))

### Removed

Expand Down
2 changes: 2 additions & 0 deletions src/Grisette/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ module Grisette.Core
FreshT (..),
runFresh,
runFreshT,
mrgRunFreshT,

-- ** Symbolic Generation Class
GenSym (..),
Expand Down Expand Up @@ -1116,6 +1117,7 @@ import Grisette.Core.Data.Class.GenSym
derivedSameShapeSimpleFresh,
genSym,
genSymSimple,
mrgRunFreshT,
name,
nameWithInfo,
runFresh,
Expand Down
8 changes: 8 additions & 0 deletions src/Grisette/Core/Data/Class/GenSym.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module Grisette.Core.Data.Class.GenSym
Fresh,
runFreshT,
runFresh,
mrgRunFreshT,

-- * Symbolic value generation
GenSym (..),
Expand Down Expand Up @@ -334,6 +335,13 @@ instance
runFreshT :: (Monad m) => FreshT m a -> FreshIdent -> m a
runFreshT m ident = fst <$> runFreshTFromIndex m ident (FreshIndex 0)

mrgRunFreshT ::
(Monad m, UnionLike m, Mergeable a) =>
FreshT m a ->
FreshIdent ->
m a
mrgRunFreshT m ident = merge $ runFreshT m ident

instance (Functor f) => Functor (FreshT f) where
fmap f (FreshT s) = FreshT $ \ident idx -> first f <$> s ident idx

Expand Down

0 comments on commit 2bc901a

Please sign in to comment.