Skip to content

Commit

Permalink
Fix #688
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed May 10, 2024
1 parent ac7a871 commit 31396a5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Data/SBV/Core/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ import Data.Maybe (fromMaybe, mapMaybe)
import Data.String (IsString(..))
import Data.Word (Word8, Word16, Word32, Word64)

import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE

import qualified Data.Set as Set

import Data.Proxy
Expand Down Expand Up @@ -959,6 +962,13 @@ instance OrdSymbolic a => OrdSymbolic [a] where
_ .< [] = sFalse
(x:xs) .< (y:ys) = x .< y .|| (x .== y .&& xs .< ys)

-- NonEmpty
instance EqSymbolic a => EqSymbolic (NonEmpty a) where
(x :| xs) .== (y :| ys) = x : xs .== y : ys

instance OrdSymbolic a => OrdSymbolic (NonEmpty a) where
(x :| xs) .< (y :| ys) = x : xs .< y : ys

-- Maybe
instance EqSymbolic a => EqSymbolic (Maybe a) where
Nothing .== Nothing = sTrue
Expand Down Expand Up @@ -2042,6 +2052,15 @@ instance Mergeable a => Mergeable [a] where
"Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."
where (lxs, lys) = (length xs, length ys)

-- NonEmpty
instance Mergeable a => Mergeable (NonEmpty a) where
symbolicMerge f t xs ys
| lxs == lys = NE.zipWith (symbolicMerge f t) xs ys
| True = cannotMerge "non-empty lists"
("Branches produce different sizes: " ++ show lxs ++ " vs " ++ show lys ++ ". Must have the same length.")
"Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."
where (lxs, lys) = (length xs, length ys)

-- ZipList
instance Mergeable a => Mergeable (ZipList a) where
symbolicMerge force test (ZipList xs) (ZipList ys)
Expand Down

0 comments on commit 31396a5

Please sign in to comment.