module Cardinal where data Cardinal = F | B | L | R | D | T | FL | FR | FD | FT | BL | BR | BD | BT | LD | LT | RD | RT | FLD | FLT | FRD | FRT | BLD | BLT | BRD | BRT | I | Scalar Double | Sum Cardinal Cardinal | Difference Cardinal Cardinal | Product Cardinal Cardinal | Quotient Cardinal Cardinal deriving (Show, Eq) instance Num Cardinal where x + y = Sum x y x - y = Difference x y x * y = Product x y negate x = Product (Scalar (-1)) x abs x = x signum x = x fromInteger x = Scalar (fromIntegral x) instance Fractional Cardinal where x / y = Quotient x y recip x = Quotient (Scalar 1) x fromRational x = Scalar (fromRational x)