mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Document uncons/unsnoc.
This commit is contained in:
parent
564128a80a
commit
096680b668
@ -14,10 +14,12 @@ newtype Adjoined a = Adjoined { unAdjoined :: Seq a }
|
|||||||
fromList :: [a] -> Adjoined a
|
fromList :: [a] -> Adjoined a
|
||||||
fromList = Adjoined . Seq.fromList
|
fromList = Adjoined . Seq.fromList
|
||||||
|
|
||||||
|
-- | Destructure a non-empty Adjoined into Just the leftmost element and the rightward remainder of the Adjoined, or Nothing otherwise.
|
||||||
uncons :: Adjoined a -> Maybe (a, Adjoined a)
|
uncons :: Adjoined a -> Maybe (a, Adjoined a)
|
||||||
uncons (Adjoined v) | a :< as <- viewl v = Just (a, Adjoined as)
|
uncons (Adjoined v) | a :< as <- viewl v = Just (a, Adjoined as)
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
|
|
||||||
|
-- | Destructure a non-empty Adjoined into Just the rightmost element and the leftward remainder of the Adjoined, or Nothing otherwise.
|
||||||
unsnoc :: Adjoined a -> Maybe (Adjoined a, a)
|
unsnoc :: Adjoined a -> Maybe (Adjoined a, a)
|
||||||
unsnoc (Adjoined v) | as :> a <- viewr v = Just (Adjoined as, a)
|
unsnoc (Adjoined v) | as :> a <- viewr v = Just (Adjoined as, a)
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
|
Loading…
Reference in New Issue
Block a user