Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions semialign/semialign.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ library
, tagged >=0.8.6 && <0.9
, unordered-containers >=0.2.8.0 && <0.3
, vector >=0.12.0.2 && <0.13
, witherable-class >=0 && <0.1

-- base shims
if !impl(ghc >=8.2)
Expand Down
10 changes: 5 additions & 5 deletions semialign/src/Data/Semialign/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import Data.Functor.Product (Product (..))
import Data.Hashable (Hashable (..))
import Data.HashMap.Strict (HashMap)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Maybe (catMaybes)
import Data.Proxy (Proxy (..))
import Data.Semigroup (Option (..), Semigroup (..))
import Data.Sequence (Seq)
import Data.Tagged (Tagged (..))
import Data.Vector.Fusion.Stream.Monadic (Step (..), Stream (..))
import Data.Vector.Generic (Vector, empty, stream, unstream)
import Data.Witherable.Class (Filterable, catMaybes)

import qualified Data.HashMap.Strict as HM
import qualified Data.List.NonEmpty as NE
Expand Down Expand Up @@ -744,17 +744,17 @@ padZipWith :: (Semialign f) => (Maybe a -> Maybe b -> c) -> f a -> f b -> f c
padZipWith f xs ys = uncurry f <$> padZip xs ys

-- | Left-padded 'zipWith'.
lpadZipWith :: (Maybe a -> b -> c) -> [a] -> [b] -> [c]
lpadZipWith :: (Semialign f, Filterable f) => (Maybe a -> b -> c) -> f a -> f b -> f c
lpadZipWith f xs ys = catMaybes $ padZipWith (\x y -> f x <$> y) xs ys

-- | Left-padded 'zip'.
lpadZip :: [a] -> [b] -> [(Maybe a, b)]
lpadZip :: (Semialign f, Filterable f) => f a -> f b -> f (Maybe a, b)
lpadZip = lpadZipWith (,)

-- | Right-padded 'zipWith'.
rpadZipWith :: (a -> Maybe b -> c) -> [a] -> [b] -> [c]
rpadZipWith :: (Semialign f, Filterable f) => (a -> Maybe b -> c) -> f a -> f b -> f c
rpadZipWith f xs ys = lpadZipWith (flip f) ys xs

-- | Right-padded 'zip'.
rpadZip :: [a] -> [b] -> [(a, Maybe b)]
rpadZip :: (Semialign f, Filterable f) => f a -> f b -> f (a, Maybe b)
rpadZip = rpadZipWith (,)