{-# OPTIONS_GHC -Wall -fno-warn-orphans #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE OverlappingInstances #-} {-# LANGUAGE GADTs #-} module HarmTrace.Models.Test.Instances where -- Generics stuff import Generics.Instant.TH -- Parser stuff import Text.ParserCombinators.UU import Text.ParserCombinators.UU.BasicInstances hiding (Inserted) -- GTree stuff import HarmTrace.HAnTree.Tree import HarmTrace.HAnTree.ToHAnTree -- Music stuff import HarmTrace.Base.MusicRep import HarmTrace.Models.Parser import HarmTrace.Models.Test.Model import HarmTrace.Tokenizer.Tokens -- A very, very permissive model. instance ParseG NoteTest where parseG = NoteTest <$> pSatisfy recognize insertion where recognize = const True insertion = Insertion "ChordToken" (ChordToken (Note Nothing I) MajClass [] Inserted 1 0) 5 instance GTree PieceTest where gTree (PieceTest ns) = [Node (HAn 0 "Pie") (gTree ns) Nothing] instance GTree NoteTest where gTree (NoteTest c) = [Node (HAnChord c) [] Nothing] -------------------------------------------------------------------------------- -- Instances of Representable for music datatypes -------------------------------------------------------------------------------- deriveAllL allTypes $(fmap join $ mapM (\t -> gadtInstance ''ParseG t 'parseG 'parseGdefault) allTypes) {- $(fmap join $ mapM (\t -> simplInstance ''GTree t 'gTree 'gTreeDefault) allTypes) -} -------------------------------------------------------------------------------- -- ChordToken as tokens -------------------------------------------------------------------------------- instance IsLocationUpdatedBy Int ChordToken where advance p c = p + chordNumReps c