{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-} -- For the IsList (uses family) and IsString (~) instances
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708
{-# LANGUAGE PatternSynonyms, ViewPatterns #-}
#endif
{-# LANGUAGE Safe #-}

-- | Non-empty difference lists: a data structure for /O(1)/ append on non-empty lists.
module Data.DList.NonEmpty.Internal where

import Prelude (Eq (..), Ord (..), Read (..), Show (..), showParen, showString, Int, Maybe (..), Char, otherwise, (-), ($), (.), (++), Functor (..), Monad (..))
import Control.Applicative (Applicative (..))
import Data.Foldable (Foldable)
import Data.Traversable (Traversable (..))

import Control.DeepSeq (NFData (..))
import Control.Monad (ap)
import Data.Function (on)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Monoid (Endo (..), mconcat)
import Data.Semigroup (Semigroup(..))
import Data.String (IsString(..))

import qualified Data.List as List
import qualified Data.List.NonEmpty as NE
import qualified Data.Foldable as F

#ifdef MIN_VERSION_semigroupoids
import Data.Functor.Apply (Apply (..))
import Data.Functor.Bind (Bind (..))
import Data.Functor.Alt (Alt (..))
import qualified Data.Semigroup.Foldable as SF
import qualified Data.Semigroup.Traversable as ST
#endif

#ifdef __GLASGOW_HASKELL__

import Text.Read (Lexeme(Ident), lexP, parens, prec, readPrec, readListPrec,
                  readListPrecDefault)

#if __GLASGOW_HASKELL__ >= 708
-- This is for the IsList methods, which conflict with fromList, toList:
import GhcIsList (IsList)
import qualified GhcIsList
#endif

#endif

-- This interface can be used wrong.
import DListUnsafe (DList(UnsafeDList))

-- | A difference list is a function that, given a list, returns the original
-- contents of the difference list prepended to the given list.
--
-- Implemented as a newtype over @[a] -> 'NonEmpty' a@.
newtype NonEmptyDList a = NEDL { forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL :: [a] -> NonEmpty a }

-- | Convert a list to a dlist
fromNonEmpty :: NonEmpty a -> NonEmptyDList a
fromNonEmpty :: forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty (a
x :| [a]
xs) = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL forall a b. (a -> b) -> a -> b
$ (a
x forall a. a -> [a] -> NonEmpty a
:|) forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a]
xs forall a. [a] -> [a] -> [a]
++)
{-# INLINE fromNonEmpty #-}

-- | Convert a dlist to a non-empty list
toNonEmpty :: NonEmptyDList a -> NonEmpty a
toNonEmpty :: forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty = (forall a b. (a -> b) -> a -> b
$ []) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL
{-# INLINE toNonEmpty #-}

-- | Convert a dlist to a list
toList :: NonEmptyDList a -> [a]
toList :: forall a. NonEmptyDList a -> [a]
toList = forall a. NonEmpty a -> [a]
NE.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
{-# INLINE toList #-}

-- | Convert to 'DList'.
--
-- /Note:/ @dlist@ doesn't expose internals, so this have to go through list.
toDList :: NonEmptyDList a -> DList a
toDList :: forall a. NonEmptyDList a -> DList a
toDList = forall a. ([a] -> [a]) -> DList a
UnsafeDList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a] -> [a]
toEndo'
{-# INLINE toDList #-}

-- | Convert to representation of 'DList'.
toEndo :: NonEmptyDList a -> Endo [a]
toEndo :: forall a. NonEmptyDList a -> Endo [a]
toEndo = forall a. (a -> a) -> Endo a
Endo forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a] -> [a]
toEndo'
{-# INLINE toEndo #-}

-- | Convert to representation of 'DList'.
toEndo' :: NonEmptyDList a -> [a] -> [a]
toEndo' :: forall a. NonEmptyDList a -> [a] -> [a]
toEndo' = forall a. Endo a -> a -> a
appEndo forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> Endo [a]
toEndo
{-# INLINE toEndo' #-}

#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708
-- | A unidirectional pattern synonym using 'toList' in a view pattern and
-- matching on @x:xs@ such that you have the pattern @Cons x xs@
#if __GLASGOW_HASKELL__ >= 710
pattern Cons :: a -> [a] -> NonEmptyDList a
#endif
pattern $mCons :: forall {r} {a}.
NonEmptyDList a -> (a -> [a] -> r) -> ((# #) -> r) -> r
Cons x xs <- (toNonEmpty -> x :| xs)
#endif

-- | Apply a dlist to a list to get the underlying non-empty list with an extension
apply :: NonEmptyDList a -> [a] -> NonEmpty a
apply :: forall a. NonEmptyDList a -> [a] -> NonEmpty a
apply = forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL

-- | Create dlist with a single element
singleton :: a -> NonEmptyDList a
singleton :: forall a. a -> NonEmptyDList a
singleton = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> [a] -> NonEmpty a
(:|)
{-# INLINE singleton #-}

-- | /O(1)/. Prepend a single element to a dlist
infixr `cons`
cons :: a -> NonEmptyDList a -> NonEmptyDList a
cons :: forall a. a -> NonEmptyDList a -> NonEmptyDList a
cons a
x NonEmptyDList a
xs = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL (forall a. a -> NonEmpty a -> NonEmpty a
NE.cons a
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL NonEmptyDList a
xs)
{-# INLINE cons #-}

-- | /O(1)/. Append a single element to a dlist
infixl `snoc`
snoc :: NonEmptyDList a -> a -> NonEmptyDList a
snoc :: forall a. NonEmptyDList a -> a -> NonEmptyDList a
snoc NonEmptyDList a
xs a
x = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL (forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL NonEmptyDList a
xs forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a
xforall a. a -> [a] -> [a]
:))
{-# INLINE snoc #-}

-- | /O(1)/. Append dlists
append :: NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
append :: forall a. NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
append NonEmptyDList a
xs NonEmptyDList a
ys = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL (forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL NonEmptyDList a
xs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
NE.toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a] -> NonEmpty a
unNEDL NonEmptyDList a
ys)
{-# INLINE append #-}

-- | /O(spine)/. Concatenate dlists
concat1 :: NonEmpty (NonEmptyDList a) -> NonEmptyDList a
concat1 :: forall a. NonEmpty (NonEmptyDList a) -> NonEmptyDList a
concat1 = forall a. Semigroup a => NonEmpty a -> a
sconcat
{-# INLINE concat1 #-}

-- | /O(n)/. Create a dlist of the given number of elements.
--
-- Always creates a list with at least one element.
replicate :: Int -> a -> NonEmptyDList a
replicate :: forall a. Int -> a -> NonEmptyDList a
replicate Int
n a
x = forall a. ([a] -> NonEmpty a) -> NonEmptyDList a
NEDL forall a b. (a -> b) -> a -> b
$ \[a]
xs -> let go :: Int -> NonEmpty a
go Int
m | Int
m forall a. Ord a => a -> a -> Bool
<= Int
1 = a
x forall a. a -> [a] -> NonEmpty a
:| [a]
xs
                                     | Bool
otherwise = forall a. a -> NonEmpty a -> NonEmpty a
NE.cons a
x forall a b. (a -> b) -> a -> b
$ Int -> NonEmpty a
go (Int
mforall a. Num a => a -> a -> a
-Int
1)
                            in Int -> NonEmpty a
go Int
n
{-# INLINE replicate #-}

-- | /O(n)/. Return the head of the dlist
head :: NonEmptyDList a -> a
head :: forall a. NonEmptyDList a -> a
head = forall a. NonEmpty a -> a
NE.head forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty

-- | /O(n)/. Return the tail of the dlist
tail :: NonEmptyDList a -> [a]
tail :: forall a. NonEmptyDList a -> [a]
tail = forall a. NonEmpty a -> [a]
NE.tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty

-- | /O(n)/. Unfoldr for dlists
unfoldr :: (b -> (a, Maybe b)) -> b -> NonEmptyDList a
unfoldr :: forall b a. (b -> (a, Maybe b)) -> b -> NonEmptyDList a
unfoldr b -> (a, Maybe b)
pf b
b = case b -> (a, Maybe b)
pf b
b of
    (a
a, Maybe b
Nothing) -> forall a. a -> NonEmptyDList a
singleton a
a
    (a
a, Just b
b')  -> forall a. a -> NonEmptyDList a -> NonEmptyDList a
cons a
a (forall b a. (b -> (a, Maybe b)) -> b -> NonEmptyDList a
unfoldr b -> (a, Maybe b)
pf b
b')

-- | /O(n)/. Map over difference lists.
map :: (a -> b) -> NonEmptyDList a -> NonEmptyDList b
map :: forall a b. (a -> b) -> NonEmptyDList a -> NonEmptyDList b
map a -> b
f = forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
{-# INLINE map #-}

instance Eq a => Eq (NonEmptyDList a) where
  == :: NonEmptyDList a -> NonEmptyDList a -> Bool
(==) = forall a. Eq a => a -> a -> Bool
(==) forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a. NonEmptyDList a -> [a]
toList

instance Ord a => Ord (NonEmptyDList a) where
  compare :: NonEmptyDList a -> NonEmptyDList a -> Ordering
compare = forall a. Ord a => a -> a -> Ordering
compare forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` forall a. NonEmptyDList a -> [a]
toList

-- The Read and Show instances were adapted from Data.Sequence.

instance Read a => Read (NonEmptyDList a) where
#ifdef __GLASGOW_HASKELL__
  readPrec :: ReadPrec (NonEmptyDList a)
readPrec = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
10 forall a b. (a -> b) -> a -> b
$ do
    Ident String
"fromNonEmpty" <- ReadPrec Lexeme
lexP
    NonEmpty a
dl <- forall a. Read a => ReadPrec a
readPrec
    forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty NonEmpty a
dl)
  readListPrec :: ReadPrec [NonEmptyDList a]
readListPrec = forall a. Read a => ReadPrec [a]
readListPrecDefault
#else
  readsPrec p = readParen (p > 10) $ \r -> do
    ("fromNonEmpty", s) <- lex r
    (dl, t) <- readsPrec 11 s
    return (fromNonEmpty dl, t)
#endif

instance Show a => Show (NonEmptyDList a) where
  showsPrec :: Int -> NonEmptyDList a -> ShowS
showsPrec Int
p NonEmptyDList a
dl = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
    String -> ShowS
showString String
"fromNonEmpty " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 (forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty NonEmptyDList a
dl)

instance Functor NonEmptyDList where
  fmap :: forall a b. (a -> b) -> NonEmptyDList a -> NonEmptyDList b
fmap = forall a b. (a -> b) -> NonEmptyDList a -> NonEmptyDList b
map
  {-# INLINE fmap #-}

instance Applicative NonEmptyDList where
  pure :: forall a. a -> NonEmptyDList a
pure = forall a. a -> NonEmptyDList a
singleton
  {-# INLINE pure #-}
  <*> :: forall a b.
NonEmptyDList (a -> b) -> NonEmptyDList a -> NonEmptyDList b
(<*>) = forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap

instance Monad NonEmptyDList where
  NonEmptyDList a
m >>= :: forall a b.
NonEmptyDList a -> (a -> NonEmptyDList b) -> NonEmptyDList b
>>= a -> NonEmptyDList b
k
    -- = concat (toList (fmap k m))
    -- = (concat . toList . fromList . List.map k . toList) m
    -- = concat . List.map k . toList $ m
    -- = List.foldr append empty . List.map k . toList $ m
    -- = List.foldr (append . k) empty . toList $ m
   = forall a. NonEmpty (NonEmptyDList a) -> NonEmptyDList a
concat1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> NonEmptyDList b
k forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty forall a b. (a -> b) -> a -> b
$ NonEmptyDList a
m
  {-# INLINE (>>=) #-}

  return :: forall a. a -> NonEmptyDList a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-# INLINE return #-}

instance Foldable NonEmptyDList where
  fold :: forall m. Monoid m => NonEmptyDList m -> m
fold = forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE fold #-}

  foldMap :: forall m a. Monoid m => (a -> m) -> NonEmptyDList a -> m
foldMap a -> m
f = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
F.foldMap a -> m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldMap #-}

  foldr :: forall a b. (a -> b -> b) -> b -> NonEmptyDList a -> b
foldr a -> b -> b
f b
x = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
List.foldr a -> b -> b
f b
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldr #-}

  foldl :: forall b a. (b -> a -> b) -> b -> NonEmptyDList a -> b
foldl b -> a -> b
f b
x = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
List.foldl b -> a -> b
f b
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldl #-}

  foldr1 :: forall a. (a -> a -> a) -> NonEmptyDList a -> a
foldr1 a -> a -> a
f = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
List.foldr1 a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldr1 #-}

  foldl1 :: forall a. (a -> a -> a) -> NonEmptyDList a -> a
foldl1 a -> a -> a
f = forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
List.foldl1 a -> a -> a
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldl1 #-}

-- CPP: foldl', foldr' added to Foldable in 7.6.1
-- http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/release-7-6-1.html
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706
  foldl' :: forall b a. (b -> a -> b) -> b -> NonEmptyDList a -> b
foldl' b -> a -> b
f b
x = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
List.foldl' b -> a -> b
f b
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldl' #-}

  foldr' :: forall a b. (a -> b -> b) -> b -> NonEmptyDList a -> b
foldr' a -> b -> b
f b
x = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr' a -> b -> b
f b
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE foldr' #-}
#endif

instance Traversable NonEmptyDList where
  traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NonEmptyDList a -> f (NonEmptyDList b)
traverse a -> f b
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse a -> f b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
  sequenceA :: forall (f :: * -> *) a.
Applicative f =>
NonEmptyDList (f a) -> f (NonEmptyDList a)
sequenceA  = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty

instance NFData a => NFData (NonEmptyDList a) where
  rnf :: NonEmptyDList a -> ()
rnf = forall a. NFData a => a -> ()
rnf forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
  {-# INLINE rnf #-}

-- This is partial instance. Will fail on empty string.
instance a ~ Char => IsString (NonEmptyDList a) where
  fromString :: String -> NonEmptyDList a
fromString = forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> NonEmpty a
NE.fromList
  {-# INLINE fromString #-}

#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708
instance IsList (NonEmptyDList a) where
  type Item (NonEmptyDList a) = a
  fromList :: [Item (NonEmptyDList a)] -> NonEmptyDList a
fromList = forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> NonEmpty a
NE.fromList
  {-# INLINE fromList #-}
  toList :: NonEmptyDList a -> [Item (NonEmptyDList a)]
toList = forall a. NonEmptyDList a -> [a]
toList
  {-# INLINE toList #-}
#endif

instance Semigroup (NonEmptyDList a) where
  <> :: NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
(<>) = forall a. NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
append
  {-# INLINE (<>) #-}

-------------------------------------------------------------------------------
-- semigroupoids
-------------------------------------------------------------------------------

#ifdef MIN_VERSION_semigroupoids
instance Apply NonEmptyDList where <.> :: forall a b.
NonEmptyDList (a -> b) -> NonEmptyDList a -> NonEmptyDList b
(<.>) = forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
(<*>)
instance Bind NonEmptyDList where >>- :: forall a b.
NonEmptyDList a -> (a -> NonEmptyDList b) -> NonEmptyDList b
(>>-) = forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
(>>=)

instance SF.Foldable1 NonEmptyDList where
  foldMap1 :: forall m a. Semigroup m => (a -> m) -> NonEmptyDList a -> m
foldMap1 a -> m
f = forall (t :: * -> *) m a.
(Foldable1 t, Semigroup m) =>
(a -> m) -> t a -> m
SF.foldMap1 a -> m
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
#if MIN_VERSION_semigroupoids(5,2,1)
  toNonEmpty :: forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty = forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
#endif

instance ST.Traversable1 NonEmptyDList where
  traverse1 :: forall (f :: * -> *) a b.
Apply f =>
(a -> f b) -> NonEmptyDList a -> f (NonEmptyDList b)
traverse1 a -> f b
f = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) a b.
(Traversable1 t, Apply f) =>
(a -> f b) -> t a -> f (t b)
ST.traverse1 a -> f b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty
  sequence1 :: forall (f :: * -> *) b.
Apply f =>
NonEmptyDList (f b) -> f (NonEmptyDList b)
sequence1   = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. NonEmpty a -> NonEmptyDList a
fromNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (f :: * -> *) b.
(Traversable1 t, Apply f) =>
t (f b) -> f (t b)
ST.sequence1 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmptyDList a -> NonEmpty a
toNonEmpty

instance Alt NonEmptyDList where
  <!> :: forall a. NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
(<!>) = forall a. NonEmptyDList a -> NonEmptyDList a -> NonEmptyDList a
append
#endif