module Pandora.Paradigm.Primary.Object.Numerator where

import Pandora.Pattern.Category (($))
import Pandora.Pattern.Object.Setoid (Setoid ((==)))
import Pandora.Pattern.Object.Chain (Chain ((<=>)))
import Pandora.Pattern.Object.Semigroup (Semigroup ((+)))
import Pandora.Pattern.Object.Ringoid (Ringoid ((*)))
import Pandora.Pattern.Object.Monoid (Monoid (zero))
import Pandora.Pattern.Object.Quasiring (Quasiring (one))
import Pandora.Paradigm.Primary.Object.Boolean (Boolean (True, False))
import Pandora.Paradigm.Primary.Object.Ordering (Ordering (Less, Equal, Greater))
import Pandora.Paradigm.Primary.Object.Denumerator (Denumerator (One))

data Numerator = Zero | Numerator Denumerator

instance Setoid Numerator where
	Numerator
Zero == :: Numerator -> Numerator -> Boolean
== Numerator
Zero = Boolean
True
	Numerator Denumerator
n == Numerator Denumerator
m = Denumerator
n Denumerator -> Denumerator -> Boolean
forall a. Setoid a => a -> a -> Boolean
== Denumerator
m
	Numerator
_ == Numerator
_ = Boolean
False

instance Chain Numerator where
	Numerator
Zero <=> :: Numerator -> Numerator -> Ordering
<=> Numerator
Zero = Ordering
Equal
	Numerator
Zero <=> Numerator Denumerator
_ = Ordering
Less
	Numerator Denumerator
_ <=> Numerator
Zero = Ordering
Greater
	Numerator Denumerator
n <=> Numerator Denumerator
m = Denumerator
n Denumerator -> Denumerator -> Ordering
forall a. Chain a => a -> a -> Ordering
<=> Denumerator
m

instance Semigroup Numerator where
	Numerator
Zero + :: Numerator -> Numerator -> Numerator
+ Numerator
m = Numerator
m
	Numerator Denumerator
n + Numerator
Zero = Denumerator -> Numerator
Numerator Denumerator
n
	Numerator Denumerator
n + Numerator Denumerator
m = Denumerator -> Numerator
Numerator (Denumerator -> Numerator) -> Denumerator -> Numerator
forall (m :: * -> * -> *) a b. Category m => m a b -> m a b
$ Denumerator
n Denumerator -> Denumerator -> Denumerator
forall a. Semigroup a => a -> a -> a
+ Denumerator
m

instance Ringoid Numerator where
	Numerator
Zero * :: Numerator -> Numerator -> Numerator
* Numerator
_ = Numerator
Zero
	Numerator Denumerator
_ * Numerator
Zero = Numerator
Zero
	Numerator Denumerator
n * Numerator Denumerator
m = Denumerator -> Numerator
Numerator (Denumerator -> Numerator) -> Denumerator -> Numerator
forall (m :: * -> * -> *) a b. Category m => m a b -> m a b
$ Denumerator
m Denumerator -> Denumerator -> Denumerator
forall a. Semigroup a => a -> a -> a
+ Denumerator
n Denumerator -> Denumerator -> Denumerator
forall a. Ringoid a => a -> a -> a
* Denumerator
m

instance Monoid Numerator where
	zero :: Numerator
zero = Numerator
Zero

instance Quasiring Numerator where
	one :: Numerator
one = Denumerator -> Numerator
Numerator Denumerator
One