{-# LANGUAGE FlexibleInstances #-}
module Musicology.MidiNumInstances where

import Musicology.Pitch

instance Num (Pitch MidiInterval) where
  fromInteger :: Integer -> Pitch MidiInterval
fromInteger = MidiInterval -> Pitch MidiInterval
forall a. a -> Pitch a
Pitch (MidiInterval -> Pitch MidiInterval)
-> (Integer -> MidiInterval) -> Integer -> Pitch MidiInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> MidiInterval
forall a. Num a => Integer -> a
fromInteger

instance Num (Pitch MidiIC) where
  fromInteger :: Integer -> Pitch MidiIC
fromInteger = MidiIC -> Pitch MidiIC
forall a. a -> Pitch a
Pitch (MidiIC -> Pitch MidiIC)
-> (Integer -> MidiIC) -> Integer -> Pitch MidiIC
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC)
-> (Integer -> MidiInterval) -> Integer -> MidiIC
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> MidiInterval
forall a. Num a => Integer -> a
fromInteger

instance Num MidiIC where
  fromInteger :: Integer -> MidiIC
fromInteger = MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC)
-> (Integer -> MidiInterval) -> Integer -> MidiIC
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> MidiInterval
forall a. Num a => Integer -> a
fromInteger
  (MidiIC MidiInterval
a) + :: MidiIC -> MidiIC -> MidiIC
+ (MidiIC MidiInterval
b) = MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC) -> MidiInterval -> MidiIC
forall a b. (a -> b) -> a -> b
$ MidiInterval
aMidiInterval -> MidiInterval -> MidiInterval
forall a. Num a => a -> a -> a
+MidiInterval
b
  (MidiIC MidiInterval
a) - :: MidiIC -> MidiIC -> MidiIC
- (MidiIC MidiInterval
b) = MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC) -> MidiInterval -> MidiIC
forall a b. (a -> b) -> a -> b
$ MidiInterval
aMidiInterval -> MidiInterval -> MidiInterval
forall a. Num a => a -> a -> a
-MidiInterval
b
  (MidiIC MidiInterval
a) * :: MidiIC -> MidiIC -> MidiIC
* (MidiIC MidiInterval
b) = MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC) -> MidiInterval -> MidiIC
forall a b. (a -> b) -> a -> b
$ MidiInterval
aMidiInterval -> MidiInterval -> MidiInterval
forall a. Num a => a -> a -> a
*MidiInterval
b -- never use this one!
  negate :: MidiIC -> MidiIC
negate (MidiIC MidiInterval
i) = MidiInterval -> MidiIC
mic (-MidiInterval
i)
  abs :: MidiIC -> MidiIC
abs = MidiIC -> MidiIC
forall a. a -> a
id
  signum :: MidiIC -> MidiIC
signum (MidiIC MidiInterval
i) = MidiInterval -> MidiIC
mic (MidiInterval -> MidiIC) -> MidiInterval -> MidiIC
forall a b. (a -> b) -> a -> b
$ MidiInterval -> MidiInterval
forall a. Num a => a -> a
signum MidiInterval
i