Skip to content

Commit

Permalink
Generalize project/embed signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Nov 7, 2024
1 parent ed3fc26 commit 1f4425c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
* Hackage: <http://hackage.haskell.org/package/sbv>
* GitHub: <http://github.com/LeventErkok/sbv>

### Version 11.0.5, Not yet released

* Generalize the signatures of the default project-embed implementations of the Queriable class.

### Version 11.0, 2024-11-06

* [BACKWARDS COMPATIBILITY] SBV now handles arrays in a much more uniform way, unifying
Expand Down
8 changes: 5 additions & 3 deletions Data/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,14 +1776,16 @@ class Queriable m a where
-- via the 'QueryT' monad transformer.
embed :: QueryResult a -> QueryT m a

default project :: (a ~ t (SBV e), QueryResult a ~ t e, Traversable t, MonadIO m, SymVal e) => a -> QueryT m (QueryResult a)
default project :: (a ~ t e, QueryResult (t e) ~ t (QueryResult e), Traversable t, Monad m, Queriable m e) => a -> QueryT m (QueryResult a)
project = mapM project

default embed :: (a ~ t (SBV e), QueryResult a ~ t e, Traversable t, MonadIO m, SymVal e) => QueryResult a -> QueryT m a
default embed :: (a ~ t e, QueryResult (t e) ~ t (QueryResult e), Traversable t, Monad m, Queriable m e) => QueryResult a -> QueryT m a
embed = mapM embed
{-# MINIMAL create #-}

-- | Generic 'Queriable' instance for 'SymVal' values
-- | Generic 'Queriable' instance for 'SymVal' values. This provides the base case for the generic definitions for project and embed
-- when we automatically derive them. We make this instance overlappable should the user have a different mapping in mind, for instance
-- mapping a symbolic boolean to a concrete integer for whatever reason.
instance {-# OVERLAPPABLE #-} (MonadIO m, SymVal a) => Queriable m (SBV a) where
type QueryResult (SBV a) = a

Expand Down

0 comments on commit 1f4425c

Please sign in to comment.