From 67e1522d2e6a3cfe61f1d9ea3289bd42fddc581e Mon Sep 17 00:00:00 2001 From: Isaac Shapira Date: Fri, 13 Jul 2018 14:49:35 -0600 Subject: [PATCH 1/5] add fromAlt --- Data/These.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Data/These.hs b/Data/These.hs index cd41e29..964ddfe 100644 --- a/Data/These.hs +++ b/Data/These.hs @@ -14,9 +14,10 @@ module Data.These ( , fromThese , mergeThese , mergeTheseWith + , fromAlt -- * Traversals - , here, there + , here, there -- * Prisms , _This, _That, _These @@ -109,6 +110,9 @@ mergeThese = these id id mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c mergeTheseWith f g op t = mergeThese op $ mapThese f g t +-- | Construct these inside an Alternative. +fromAlt :: Alternative f => f a -> f b -> f (These a b) +fromAlt x y = These <$> x <*> y <|> That <$> y <|> This <$> x -- | A @Traversal@ of the first half of a 'These', suitable for use with @Control.Lens@. here :: (Applicative f) => (a -> f b) -> These a t -> f (These b t) From c8324b47dde5c4084c8d3af9ee20cb96935c06a2 Mon Sep 17 00:00:00 2001 From: Isaac Shapira Date: Fri, 13 Jul 2018 14:51:12 -0600 Subject: [PATCH 2/5] whitespace --- Data/These.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/These.hs b/Data/These.hs index 964ddfe..026c0c3 100644 --- a/Data/These.hs +++ b/Data/These.hs @@ -17,7 +17,7 @@ module Data.These ( , fromAlt -- * Traversals - , here, there + , here, there -- * Prisms , _This, _That, _These From c2c778c026c8dae66b5aabd45f8aa96cc94bfe18 Mon Sep 17 00:00:00 2001 From: Isaac Shapira Date: Fri, 13 Jul 2018 14:51:47 -0600 Subject: [PATCH 3/5] caps --- Data/These.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/These.hs b/Data/These.hs index 026c0c3..fbc9b83 100644 --- a/Data/These.hs +++ b/Data/These.hs @@ -110,7 +110,7 @@ mergeThese = these id id mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c mergeTheseWith f g op t = mergeThese op $ mapThese f g t --- | Construct these inside an Alternative. +-- | Construct These inside an Alternative. fromAlt :: Alternative f => f a -> f b -> f (These a b) fromAlt x y = These <$> x <*> y <|> That <$> y <|> This <$> x From bf06fa452473008efd4bcbe9dd375f649601aeba Mon Sep 17 00:00:00 2001 From: Isaac Shapira Date: Tue, 17 Jul 2018 11:13:34 -0600 Subject: [PATCH 4/5] change name and haddock, updated logic to prioritize error from This vs That --- Data/These.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Data/These.hs b/Data/These.hs index fbc9b83..403f8a8 100644 --- a/Data/These.hs +++ b/Data/These.hs @@ -14,7 +14,7 @@ module Data.These ( , fromThese , mergeThese , mergeTheseWith - , fromAlt + , optionally -- * Traversals , here, there @@ -110,9 +110,10 @@ mergeThese = these id id mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c mergeTheseWith f g op t = mergeThese op $ mapThese f g t --- | Construct These inside an Alternative. -fromAlt :: Alternative f => f a -> f b -> f (These a b) -fromAlt x y = These <$> x <*> y <|> That <$> y <|> This <$> x +-- | Construct These inside an Alternative. +-- Consider @Control.Applicative.optional` for intuition. +optionally :: Alternative f => f a -> f b -> f (These a b) +optionally x y = These <$> x <*> y <|> This <$> x <|> That <$> y -- | A @Traversal@ of the first half of a 'These', suitable for use with @Control.Lens@. here :: (Applicative f) => (a -> f b) -> These a t -> f (These b t) From f301605dd0bdc2df89aa49e6e308f09a5d849a97 Mon Sep 17 00:00:00 2001 From: Isaac Shapira Date: Tue, 17 Jul 2018 11:20:06 -0600 Subject: [PATCH 5/5] fix commend --- Data/These.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/These.hs b/Data/These.hs index 403f8a8..dd55c40 100644 --- a/Data/These.hs +++ b/Data/These.hs @@ -111,7 +111,7 @@ mergeTheseWith :: (a -> c) -> (b -> c) -> (c -> c -> c) -> These a b -> c mergeTheseWith f g op t = mergeThese op $ mapThese f g t -- | Construct These inside an Alternative. --- Consider @Control.Applicative.optional` for intuition. +-- Consider @Control.Applicative.optional@ for intuition. optionally :: Alternative f => f a -> f b -> f (These a b) optionally x y = These <$> x <*> y <|> This <$> x <|> That <$> y