module Music.Score.Meta.Barline (
BarlineType(..),
Barline,
barline,
doubleBarline,
finalBarline,
barlineDuring,
withBarline,
) where
import Control.Lens (view)
import Control.Monad.Plus
import Data.Foldable (Foldable)
import qualified Data.Foldable as F
import qualified Data.List as List
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
import Data.Semigroup
import Data.Set (Set)
import qualified Data.Set as Set
import Data.String
import Data.Traversable (Traversable)
import qualified Data.Traversable as T
import Data.Typeable
import Music.Pitch.Literal
import Music.Score.Meta
import Music.Score.Part
import Music.Score.Pitch
import Music.Score.Internal.Util
import Music.Time
import Music.Time.Reactive
data Barline = Barline BarlineType
deriving (Eq, Ord, Show, Typeable)
data BarlineType = StandardBarline | DoubleBarline | FinalBarline
deriving (Eq, Ord, Show, Typeable)
barline :: (HasMeta a, HasPosition a) => Barline -> a -> a
barline c x = barlineDuring (_era x) c x
doubleBarline :: (HasMeta a, HasPosition a) => Barline -> a -> a
doubleBarline = undefined
finalBarline :: (HasMeta a, HasPosition a) => Barline -> a -> a
finalBarline = undefined
barlineDuring :: HasMeta a => Span -> Barline -> a -> a
barlineDuring s c = addMetaNote $ view event (s, (Option $ Just $ Last c))
withBarline :: (Barline -> Score a -> Score a) -> Score a -> Score a
withBarline f = withMeta (maybe id f . fmap getLast . getOption)