ddssff/listlike

unsnoc

Opened this issue · 0 comments

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)