unison-prelude-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Util.List

Synopsis

Documentation

multimap :: Foldable f => Ord k => f (k, v) -> Map k [v] Source #

groupBy :: (Foldable f, Ord k) => (v -> k) -> f v -> Map k [v] Source #

groupMap :: (Foldable f, Eq k) => (a -> (k, b)) -> f a -> [(k, [b])] Source #

group _consecutive_ elements by a key. e.g. >>> groupMap (n -> (odd n, show n)) [1, 3, 4, 6, 7] [(True,["1","3"]),(False,["4","6"]),(True,["7"])]

uniqueBy :: (Foldable f, Ord b) => (a -> b) -> f a -> [a] Source #

nubOrdOn :: (Foldable f, Ord b) => (a -> b) -> f a -> [a] Source #

uniqueBy' :: (Foldable f, Ord b) => (a -> b) -> f a -> [a] Source #

safeHead :: Foldable f => f a -> Maybe a Source #

validate :: (Semigroup e, Foldable f) => (a -> Either e b) -> f a -> Either e [b] Source #

intercalateMapWith :: (a -> a -> b) -> (a -> b) -> [a] -> [b] Source #

quenchRuns :: Eq a => a -> a -> [a] -> [a] Source #

splitOnLongestCommonPrefix :: Eq a => [a] -> [a] -> ([a], [a], [a]) Source #

Finds the longest shared path prefix of two paths. Returns (shared prefix, path to first location from shared prefix, path to second location from shared prefix)

>>> splitOnLongestCommonPrefix ["a", "b", "x"] ["a", "b", "c"]
(["a","b"],["x"],["c"])
>>> splitOnLongestCommonPrefix [] ["a", "b", "c"]
([],[],["a","b","c"])