{-# LANGUAGE DeriveTraversable, GeneralizedNewtypeDeriving #-}
module Data.Semilattice.Order
( Order(..)
) where
import Data.Semilattice.Join
import Data.Semilattice.Lower
import Data.Semilattice.Meet
import Data.Semilattice.Upper
newtype Order a = Order { forall a. Order a -> a
getOrder :: a }
deriving (Order a
Order a -> Order a -> Bounded (Order a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Order a
$cminBound :: forall a. Bounded a => Order a
minBound :: Order a
$cmaxBound :: forall a. Bounded a => Order a
maxBound :: Order a
Bounded, Int -> Order a
Order a -> Int
Order a -> [Order a]
Order a -> Order a
Order a -> Order a -> [Order a]
Order a -> Order a -> Order a -> [Order a]
(Order a -> Order a)
-> (Order a -> Order a)
-> (Int -> Order a)
-> (Order a -> Int)
-> (Order a -> [Order a])
-> (Order a -> Order a -> [Order a])
-> (Order a -> Order a -> [Order a])
-> (Order a -> Order a -> Order a -> [Order a])
-> Enum (Order a)
forall a. Enum a => Int -> Order a
forall a. Enum a => Order a -> Int
forall a. Enum a => Order a -> [Order a]
forall a. Enum a => Order a -> Order a
forall a. Enum a => Order a -> Order a -> [Order a]
forall a. Enum a => Order a -> Order a -> Order a -> [Order a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => Order a -> Order a
succ :: Order a -> Order a
$cpred :: forall a. Enum a => Order a -> Order a
pred :: Order a -> Order a
$ctoEnum :: forall a. Enum a => Int -> Order a
toEnum :: Int -> Order a
$cfromEnum :: forall a. Enum a => Order a -> Int
fromEnum :: Order a -> Int
$cenumFrom :: forall a. Enum a => Order a -> [Order a]
enumFrom :: Order a -> [Order a]
$cenumFromThen :: forall a. Enum a => Order a -> Order a -> [Order a]
enumFromThen :: Order a -> Order a -> [Order a]
$cenumFromTo :: forall a. Enum a => Order a -> Order a -> [Order a]
enumFromTo :: Order a -> Order a -> [Order a]
$cenumFromThenTo :: forall a. Enum a => Order a -> Order a -> Order a -> [Order a]
enumFromThenTo :: Order a -> Order a -> Order a -> [Order a]
Enum, Order a -> Order a -> Bool
(Order a -> Order a -> Bool)
-> (Order a -> Order a -> Bool) -> Eq (Order a)
forall a. Eq a => Order a -> Order a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Order a -> Order a -> Bool
== :: Order a -> Order a -> Bool
$c/= :: forall a. Eq a => Order a -> Order a -> Bool
/= :: Order a -> Order a -> Bool
Eq, (forall m. Monoid m => Order m -> m)
-> (forall m a. Monoid m => (a -> m) -> Order a -> m)
-> (forall m a. Monoid m => (a -> m) -> Order a -> m)
-> (forall a b. (a -> b -> b) -> b -> Order a -> b)
-> (forall a b. (a -> b -> b) -> b -> Order a -> b)
-> (forall b a. (b -> a -> b) -> b -> Order a -> b)
-> (forall b a. (b -> a -> b) -> b -> Order a -> b)
-> (forall a. (a -> a -> a) -> Order a -> a)
-> (forall a. (a -> a -> a) -> Order a -> a)
-> (forall a. Order a -> [a])
-> (forall a. Order a -> Bool)
-> (forall a. Order a -> Int)
-> (forall a. Eq a => a -> Order a -> Bool)
-> (forall a. Ord a => Order a -> a)
-> (forall a. Ord a => Order a -> a)
-> (forall a. Num a => Order a -> a)
-> (forall a. Num a => Order a -> a)
-> Foldable Order
forall a. Eq a => a -> Order a -> Bool
forall a. Num a => Order a -> a
forall a. Ord a => Order a -> a
forall m. Monoid m => Order m -> m
forall a. Order a -> Bool
forall a. Order a -> Int
forall a. Order a -> [a]
forall a. (a -> a -> a) -> Order a -> a
forall m a. Monoid m => (a -> m) -> Order a -> m
forall b a. (b -> a -> b) -> b -> Order a -> b
forall a b. (a -> b -> b) -> b -> Order a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Order m -> m
fold :: forall m. Monoid m => Order m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Order a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Order a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Order a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Order a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Order a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Order a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Order a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Order a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Order a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Order a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Order a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Order a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Order a -> a
foldr1 :: forall a. (a -> a -> a) -> Order a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Order a -> a
foldl1 :: forall a. (a -> a -> a) -> Order a -> a
$ctoList :: forall a. Order a -> [a]
toList :: forall a. Order a -> [a]
$cnull :: forall a. Order a -> Bool
null :: forall a. Order a -> Bool
$clength :: forall a. Order a -> Int
length :: forall a. Order a -> Int
$celem :: forall a. Eq a => a -> Order a -> Bool
elem :: forall a. Eq a => a -> Order a -> Bool
$cmaximum :: forall a. Ord a => Order a -> a
maximum :: forall a. Ord a => Order a -> a
$cminimum :: forall a. Ord a => Order a -> a
minimum :: forall a. Ord a => Order a -> a
$csum :: forall a. Num a => Order a -> a
sum :: forall a. Num a => Order a -> a
$cproduct :: forall a. Num a => Order a -> a
product :: forall a. Num a => Order a -> a
Foldable, (forall a b. (a -> b) -> Order a -> Order b)
-> (forall a b. a -> Order b -> Order a) -> Functor Order
forall a b. a -> Order b -> Order a
forall a b. (a -> b) -> Order a -> Order b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Order a -> Order b
fmap :: forall a b. (a -> b) -> Order a -> Order b
$c<$ :: forall a b. a -> Order b -> Order a
<$ :: forall a b. a -> Order b -> Order a
Functor, Order a
Order a -> Lower (Order a)
forall s. s -> Lower s
forall a. Lower a => Order a
$clowerBound :: forall a. Lower a => Order a
lowerBound :: Order a
Lower, Integer -> Order a
Order a -> Order a
Order a -> Order a -> Order a
(Order a -> Order a -> Order a)
-> (Order a -> Order a -> Order a)
-> (Order a -> Order a -> Order a)
-> (Order a -> Order a)
-> (Order a -> Order a)
-> (Order a -> Order a)
-> (Integer -> Order a)
-> Num (Order a)
forall a. Num a => Integer -> Order a
forall a. Num a => Order a -> Order a
forall a. Num a => Order a -> Order a -> Order a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: forall a. Num a => Order a -> Order a -> Order a
+ :: Order a -> Order a -> Order a
$c- :: forall a. Num a => Order a -> Order a -> Order a
- :: Order a -> Order a -> Order a
$c* :: forall a. Num a => Order a -> Order a -> Order a
* :: Order a -> Order a -> Order a
$cnegate :: forall a. Num a => Order a -> Order a
negate :: Order a -> Order a
$cabs :: forall a. Num a => Order a -> Order a
abs :: Order a -> Order a
$csignum :: forall a. Num a => Order a -> Order a
signum :: Order a -> Order a
$cfromInteger :: forall a. Num a => Integer -> Order a
fromInteger :: Integer -> Order a
Num, Eq (Order a)
Eq (Order a) =>
(Order a -> Order a -> Ordering)
-> (Order a -> Order a -> Bool)
-> (Order a -> Order a -> Bool)
-> (Order a -> Order a -> Bool)
-> (Order a -> Order a -> Bool)
-> (Order a -> Order a -> Order a)
-> (Order a -> Order a -> Order a)
-> Ord (Order a)
Order a -> Order a -> Bool
Order a -> Order a -> Ordering
Order a -> Order a -> Order 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 (Order a)
forall a. Ord a => Order a -> Order a -> Bool
forall a. Ord a => Order a -> Order a -> Ordering
forall a. Ord a => Order a -> Order a -> Order a
$ccompare :: forall a. Ord a => Order a -> Order a -> Ordering
compare :: Order a -> Order a -> Ordering
$c< :: forall a. Ord a => Order a -> Order a -> Bool
< :: Order a -> Order a -> Bool
$c<= :: forall a. Ord a => Order a -> Order a -> Bool
<= :: Order a -> Order a -> Bool
$c> :: forall a. Ord a => Order a -> Order a -> Bool
> :: Order a -> Order a -> Bool
$c>= :: forall a. Ord a => Order a -> Order a -> Bool
>= :: Order a -> Order a -> Bool
$cmax :: forall a. Ord a => Order a -> Order a -> Order a
max :: Order a -> Order a -> Order a
$cmin :: forall a. Ord a => Order a -> Order a -> Order a
min :: Order a -> Order a -> Order a
Ord, ReadPrec [Order a]
ReadPrec (Order a)
Int -> ReadS (Order a)
ReadS [Order a]
(Int -> ReadS (Order a))
-> ReadS [Order a]
-> ReadPrec (Order a)
-> ReadPrec [Order a]
-> Read (Order a)
forall a. Read a => ReadPrec [Order a]
forall a. Read a => ReadPrec (Order a)
forall a. Read a => Int -> ReadS (Order a)
forall a. Read a => ReadS [Order a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Order a)
readsPrec :: Int -> ReadS (Order a)
$creadList :: forall a. Read a => ReadS [Order a]
readList :: ReadS [Order a]
$creadPrec :: forall a. Read a => ReadPrec (Order a)
readPrec :: ReadPrec (Order a)
$creadListPrec :: forall a. Read a => ReadPrec [Order a]
readListPrec :: ReadPrec [Order a]
Read, Int -> Order a -> ShowS
[Order a] -> ShowS
Order a -> String
(Int -> Order a -> ShowS)
-> (Order a -> String) -> ([Order a] -> ShowS) -> Show (Order a)
forall a. Show a => Int -> Order a -> ShowS
forall a. Show a => [Order a] -> ShowS
forall a. Show a => Order a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Order a -> ShowS
showsPrec :: Int -> Order a -> ShowS
$cshow :: forall a. Show a => Order a -> String
show :: Order a -> String
$cshowList :: forall a. Show a => [Order a] -> ShowS
showList :: [Order a] -> ShowS
Show, Functor Order
Foldable Order
(Functor Order, Foldable Order) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Order a -> f (Order b))
-> (forall (f :: * -> *) a.
Applicative f =>
Order (f a) -> f (Order a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Order a -> m (Order b))
-> (forall (m :: * -> *) a. Monad m => Order (m a) -> m (Order a))
-> Traversable Order
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Order (m a) -> m (Order a)
forall (f :: * -> *) a. Applicative f => Order (f a) -> f (Order a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Order a -> m (Order b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Order a -> f (Order b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Order a -> f (Order b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Order a -> f (Order b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Order (f a) -> f (Order a)
sequenceA :: forall (f :: * -> *) a. Applicative f => Order (f a) -> f (Order a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Order a -> m (Order b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Order a -> m (Order b)
$csequence :: forall (m :: * -> *) a. Monad m => Order (m a) -> m (Order a)
sequence :: forall (m :: * -> *) a. Monad m => Order (m a) -> m (Order a)
Traversable, Order a
Order a -> Upper (Order a)
forall s. s -> Upper s
forall a. Upper a => Order a
$cupperBound :: forall a. Upper a => Order a
upperBound :: Order a
Upper)
instance Ord a => Join (Order a) where
Order a
a \/ :: Order a -> Order a -> Order a
\/ Order a
b
| Order a
a Order a -> Order a -> Bool
forall a. Ord a => a -> a -> Bool
<= Order a
b = Order a
b
| Bool
otherwise = Order a
a
instance Ord a => Meet (Order a) where
Order a
a /\ :: Order a -> Order a -> Order a
/\ Order a
b
| Order a
a Order a -> Order a -> Bool
forall a. Ord a => a -> a -> Bool
<= Order a
b = Order a
a
| Bool
otherwise = Order a
b