nikita-volkov / refined

Refinement types with static checking
http://hackage.haskell.org/package/refined
MIT License
183 stars 31 forks source link

`strengthen` does too much work #72

Closed chessai closed 2 years ago

chessai commented 3 years ago

Type:

strengthen :: forall p p' x. (Predicate p x, Predicate p' x)
  => Refined p x
  -> Either RefineException (Refined (p && p') x)

Current implementation:

strengthen = unrefine .> refine

Proposed implementation:

strengthen r = do
  Refined x <- refine @p' @x (unrefined r)
  pure (Refined x)

Since p, p' are effectively functions a -> Bool, we needn't check p again.

chessai commented 2 years ago

this is now fixed in master