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