Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsnoc #25

Open
chris-martin opened this issue Feb 17, 2023 · 0 comments
Open

unsnoc #25

chris-martin opened this issue Feb 17, 2023 · 0 comments

Comments

@chris-martin
Copy link

Something seems missing from this picture:

consuncons
snoc-

I would like to propose adding unsnoc to fill in this gap.

cons   :: ListLike full item => item -> full -> full
snoc   :: ListLike full item => full -> item -> full
uncons :: ListLike full item => full -> Maybe (item, full)
unsnoc :: ListLike full item => full -> Maybe (full, item)

I think the naming is a little silly, but it sticks with the conventions existing in this library, and there is precedent elsewhere.

The text library:

cons   :: Char -> Text -> Text
snoc   :: Text -> Char -> Text
uncons :: Text -> Maybe (Char, Text)
unsnoc :: Text -> Maybe (Text, Char) 

The bytestring library:

cons   :: Word8 -> ByteString -> ByteString 
snoc   :: ByteString -> Word8 -> ByteString
uncons :: ByteString -> Maybe (Word8, ByteString)
unsnoc :: ByteString -> Maybe (ByteString, Word8) 
@andreasabel andreasabel mentioned this issue Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant