diff options
Diffstat (limited to 'compiler/utils/OrdList.hs')
-rw-r--r-- | compiler/utils/OrdList.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs index 9e735e7d80..4591b55978 100644 --- a/compiler/utils/OrdList.hs +++ b/compiler/utils/OrdList.hs @@ -12,7 +12,7 @@ can be appended in linear time. {-# LANGUAGE CPP #-} module OrdList ( OrdList, - nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, + nilOL, isNilOL, unitOL, appOL, consOL, snocOL, concatOL, lastOL, mapOL, fromOL, toOL, foldrOL, foldlOL ) where @@ -51,6 +51,7 @@ snocOL :: OrdList a -> a -> OrdList a consOL :: a -> OrdList a -> OrdList a appOL :: OrdList a -> OrdList a -> OrdList a concatOL :: [OrdList a] -> OrdList a +lastOL :: OrdList a -> a nilOL = None unitOL as = One as @@ -58,6 +59,13 @@ snocOL as b = Snoc as b consOL a bs = Cons a bs concatOL aas = foldr appOL None aas +lastOL None = panic "lastOL" +lastOL (One a) = a +lastOL (Many as) = last as +lastOL (Cons _ as) = lastOL as +lastOL (Snoc _ a) = a +lastOL (Two _ as) = lastOL as + isNilOL None = True isNilOL _ = False |