{-# LANGUAGE TypeFamilies #-}
module Data.Delta.List
( DeltaList (..)
) where
import Prelude
import Data.Delta.Core
( Delta (..)
)
newtype DeltaList a = Append [a]
deriving (DeltaList a -> DeltaList a -> Bool
(DeltaList a -> DeltaList a -> Bool)
-> (DeltaList a -> DeltaList a -> Bool) -> Eq (DeltaList a)
forall a. Eq a => DeltaList a -> DeltaList a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => DeltaList a -> DeltaList a -> Bool
== :: DeltaList a -> DeltaList a -> Bool
$c/= :: forall a. Eq a => DeltaList a -> DeltaList a -> Bool
/= :: DeltaList a -> DeltaList a -> Bool
Eq, Eq (DeltaList a)
Eq (DeltaList a) =>
(DeltaList a -> DeltaList a -> Ordering)
-> (DeltaList a -> DeltaList a -> Bool)
-> (DeltaList a -> DeltaList a -> Bool)
-> (DeltaList a -> DeltaList a -> Bool)
-> (DeltaList a -> DeltaList a -> Bool)
-> (DeltaList a -> DeltaList a -> DeltaList a)
-> (DeltaList a -> DeltaList a -> DeltaList a)
-> Ord (DeltaList a)
DeltaList a -> DeltaList a -> Bool
DeltaList a -> DeltaList a -> Ordering
DeltaList a -> DeltaList a -> DeltaList a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (DeltaList a)
forall a. Ord a => DeltaList a -> DeltaList a -> Bool
forall a. Ord a => DeltaList a -> DeltaList a -> Ordering
forall a. Ord a => DeltaList a -> DeltaList a -> DeltaList a
$ccompare :: forall a. Ord a => DeltaList a -> DeltaList a -> Ordering
compare :: DeltaList a -> DeltaList a -> Ordering
$c< :: forall a. Ord a => DeltaList a -> DeltaList a -> Bool
< :: DeltaList a -> DeltaList a -> Bool
$c<= :: forall a. Ord a => DeltaList a -> DeltaList a -> Bool
<= :: DeltaList a -> DeltaList a -> Bool
$c> :: forall a. Ord a => DeltaList a -> DeltaList a -> Bool
> :: DeltaList a -> DeltaList a -> Bool
$c>= :: forall a. Ord a => DeltaList a -> DeltaList a -> Bool
>= :: DeltaList a -> DeltaList a -> Bool
$cmax :: forall a. Ord a => DeltaList a -> DeltaList a -> DeltaList a
max :: DeltaList a -> DeltaList a -> DeltaList a
$cmin :: forall a. Ord a => DeltaList a -> DeltaList a -> DeltaList a
min :: DeltaList a -> DeltaList a -> DeltaList a
Ord, Int -> DeltaList a -> ShowS
[DeltaList a] -> ShowS
DeltaList a -> String
(Int -> DeltaList a -> ShowS)
-> (DeltaList a -> String)
-> ([DeltaList a] -> ShowS)
-> Show (DeltaList a)
forall a. Show a => Int -> DeltaList a -> ShowS
forall a. Show a => [DeltaList a] -> ShowS
forall a. Show a => DeltaList a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> DeltaList a -> ShowS
showsPrec :: Int -> DeltaList a -> ShowS
$cshow :: forall a. Show a => DeltaList a -> String
show :: DeltaList a -> String
$cshowList :: forall a. Show a => [DeltaList a] -> ShowS
showList :: [DeltaList a] -> ShowS
Show)
instance Delta (DeltaList a) where
type Base (DeltaList a) = [a]
apply :: DeltaList a -> Base (DeltaList a) -> Base (DeltaList a)
apply (Append [a]
xs) Base (DeltaList a)
ys = [a]
xs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
Base (DeltaList a)
ys
instance Ord a => Semigroup (DeltaList a) where
(Append [a]
xs) <> :: DeltaList a -> DeltaList a -> DeltaList a
<> (Append [a]
ys) = [a] -> DeltaList a
forall a. [a] -> DeltaList a
Append ([a]
xs [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ [a]
ys)
instance Ord a => Monoid (DeltaList a) where
mempty :: DeltaList a
mempty = [a] -> DeltaList a
forall a. [a] -> DeltaList a
Append []