From 115549407ca6f785489c220f181577bb6a7d6987 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 11 Mar 2016 18:40:45 -0500 Subject: [PATCH] Add an unsnoc function to unpack the right side of an Adjoined. --- src/Data/Adjoined.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/Adjoined.hs b/src/Data/Adjoined.hs index d38668621..c248f09c9 100644 --- a/src/Data/Adjoined.hs +++ b/src/Data/Adjoined.hs @@ -16,6 +16,10 @@ uncons :: Adjoined a -> Maybe (a, Adjoined a) uncons (Adjoined v) | a :< as <- viewl v = Just (a, Adjoined as) | otherwise = Nothing +unsnoc :: Adjoined a -> Maybe (Adjoined a, a) +unsnoc (Adjoined v) | as :> a <- viewr v = Just (Adjoined as, a) + | otherwise = Nothing + instance Applicative Adjoined where pure = return (<*>) = ap