music-score-1.7.2: src/Music/Time/Nominal.hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
-------------------------------------------------------------------------------------
-- |
-- Copyright : (c) Hans Hoglund 2012–2014
--
-- License : BSD-style
--
-- Maintainer : hans@hanshoglund.se
-- Stability : experimental
-- Portability : non-portable (TF,GNTD)
--
-------------------------------------------------------------------------------------
module Music.Time.Nominal where
import Control.Applicative
import Control.Monad
import Control.Monad.Compose
import Control.Monad.Plus
import Data.Foldable (Foldable)
import qualified Data.Foldable as Foldable
import Data.Traversable (Traversable)
import qualified Data.Traversable as T
import Data.Typeable
import Music.Time.Split
import Music.Time.Reverse
newtype Nominal f a = Nominal { getNominal :: f a }
deriving (Eq, Ord, Read, Show, Functor, Foldable, Traversable, Monad)
instance Applicative f => Applicative (Nominal f) where
pure = Nominal . pure
Nominal f <*> Nominal x = Nominal (f <*> x)
instance Transformable (Nominal f a) where
transform _ = id
instance Splittable (Nominal f a) where
split _ x = (x,x)
instance Reversible (f a) => Reversible (Nominal f a) where
rev (Nominal x) = Nominal (rev x)