Permalink
Browse files

AsEmpty (a,b,c)

  • Loading branch information...
1 parent 978c660 commit 67f18461969404603c0786eb40e498c69064b811 @ekmett committed Mar 29, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/Control/Lens/Prism.hs
View
@@ -369,6 +369,16 @@ instance (AsEmpty a, AsEmpty b) => AsEmpty (a,b) where
Right t -> Left (t, _Empty # ())
{-# INLINE _Empty #-}
+instance (AsEmpty a, AsEmpty b, AsEmpty c) => AsEmpty (a,b,c) where
+ _Empty = prism (\() -> (_Empty # (), _Empty # (), _Empty # ())) $ \(s,s',s'') -> case _Empty Left s of
+ Left () -> case _Empty Left s' of
+ Left () -> case _Empty Left s'' of
+ Left () -> Right ()
+ Right t'' -> Left (_Empty # (), _Empty # (), t'')
+ Right t' -> Left (_Empty # (), t', _Empty # ())
+ Right t -> Left (t, _Empty # (), _Empty # ())
+ {-# INLINE _Empty #-}
+
instance AsEmpty [a] where
_Empty = nearly [] Prelude.null
{-# INLINE _Empty #-}

0 comments on commit 67f1846

Please sign in to comment.