feat(users/Profpatsch/my-prelude): inline RevList defs
Change-Id: Iab727a98a8c078ce5f32d53aa87ee149356997d4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13266 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
b21d538a27
commit
18f565567a
1 changed files with 5 additions and 0 deletions
|
|
@ -11,18 +11,23 @@ newtype RevList a = RevList [a]
|
|||
deriving (Semigroup, Monoid) via (Semigroup.Dual [a])
|
||||
|
||||
empty :: RevList a
|
||||
{-# INLINE empty #-}
|
||||
empty = RevList []
|
||||
|
||||
singleton :: a -> RevList a
|
||||
{-# INLINE singleton #-}
|
||||
singleton a = RevList [a]
|
||||
|
||||
-- | (@O(n)@) Turn the list into a reversed list (by reversing)
|
||||
revList :: [a] -> RevList a
|
||||
{-# INLINE revList #-}
|
||||
revList xs = RevList $ reverse xs
|
||||
|
||||
-- | (@O(n)@) Turn the reversed list into a list (by reversing)
|
||||
revListToList :: RevList a -> [a]
|
||||
{-# INLINE revListToList #-}
|
||||
revListToList (RevList rev) = reverse rev
|
||||
|
||||
instance (Show a) => Show (RevList a) where
|
||||
{-# INLINE show #-}
|
||||
show (RevList rev) = rev & show
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue