ekmett / ersatz

A monad for interfacing with external SAT solvers
Other
63 stars 15 forks source link

rows, colums of relation #99

Open jwaldmann opened 1 month ago

jwaldmann commented 1 month ago

I sometimes want to convert between R.Relation a b and [[Bit]]. It's easy to write

rows b =
  let ((u,l),(o,r)) = R.bounds b
  in  flip map (A.range (u,o)) $ \ x ->
         flip map (A.range (l,r)) $ \ y ->
         b R.! (x,y)

but it could be in the library.

Actually, it already is, sort of, but hidden in the implementation of https://hackage.haskell.org/package/ersatz-0.5/docs/src/Ersatz.Relation.Data.html#table