Skip to content

Commit

Permalink
Added sans.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Feb 18, 2013
1 parent e464a2a commit 1be77fc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Control/Lens/At.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
module Control.Lens.At
(
-- * At
At(at)
At(at), sans
-- * Ixed
, IxValue
, Ixed(ix)
Expand All @@ -48,6 +48,7 @@ import Control.Lens.Each
import Control.Lens.Fold
import Control.Lens.Getter
import Control.Lens.Indexed as Lens
import Control.Lens.Setter
import Control.Lens.Type
import Control.Lens.Traversal
import Data.Array.IArray as Array
Expand Down Expand Up @@ -523,6 +524,10 @@ class At m where
-- you cannot satisfy the 'Lens' laws.
at :: Index m -> IndexedLens' (Index m) m (Maybe (IxValue m))

sans :: At m => Index m -> m -> m
sans k m = m & at k .~ Nothing
{-# INLINE sans #-}

instance At (IntMap a) where
at k f m = Lens.indexed f k mv <&> \r -> case r of
Nothing -> maybe m (const (IntMap.delete k m)) mv
Expand Down

0 comments on commit 1be77fc

Please sign in to comment.