Created
July 31, 2014 01:49
-
-
Save lambda-fairy/bf987a6215a81e47cf9a to your computer and use it in GitHub Desktop.
Data.CaseInsensitive and (Co)Traversable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| traverse :: (FoldCase s1, FoldCase s2, Functor f) => (s1 -> f s2) -> CI s1 -> f (CI s2) | |
| traverse f = fmap CI.mk . f . CI.original | |
| cotraverse :: (FoldCase s1, FoldCase s2, Functor f) => (f s1 -> s2) -> f (CI s1) -> CI s2 | |
| cotraverse f = CI.mk . f . fmap CI.original | |
| -- Examples | |
| concat :: [CI ByteString] -> CI ByteString | |
| concat = cotraverse B.concat | |
| intercalate :: ByteString -> [CI ByteString] -> CI ByteString | |
| intercalate s = cotraverse (B.intercalate s) | |
| inits :: CI ByteString -> [CI ByteString] | |
| inits = traverse B.inits | |
| uncons :: CI ByteString -> Maybe (Word8, CI ByteString) | |
| uncons = getCompose . traverse (Compose . B.uncons) | |
| transpose :: [CI ByteString] -> [CI ByteString] | |
| transpose = undefined -- ?? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment