module Instrument.InstT where
import qualified Data.Text as Text
import qualified Util.Serialize as Serialize
import Global
data Qualified = Qualified SynthName Name deriving (Int -> Qualified -> ShowS
[Qualified] -> ShowS
Qualified -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Qualified] -> ShowS
$cshowList :: [Qualified] -> ShowS
show :: Qualified -> String
$cshow :: Qualified -> String
showsPrec :: Int -> Qualified -> ShowS
$cshowsPrec :: Int -> Qualified -> ShowS
Show, Qualified -> Qualified -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Qualified -> Qualified -> Bool
$c/= :: Qualified -> Qualified -> Bool
== :: Qualified -> Qualified -> Bool
$c== :: Qualified -> Qualified -> Bool
Eq, Eq Qualified
Qualified -> Qualified -> Bool
Qualified -> Qualified -> Ordering
Qualified -> Qualified -> Qualified
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Qualified -> Qualified -> Qualified
$cmin :: Qualified -> Qualified -> Qualified
max :: Qualified -> Qualified -> Qualified
$cmax :: Qualified -> Qualified -> Qualified
>= :: Qualified -> Qualified -> Bool
$c>= :: Qualified -> Qualified -> Bool
> :: Qualified -> Qualified -> Bool
$c> :: Qualified -> Qualified -> Bool
<= :: Qualified -> Qualified -> Bool
$c<= :: Qualified -> Qualified -> Bool
< :: Qualified -> Qualified -> Bool
$c< :: Qualified -> Qualified -> Bool
compare :: Qualified -> Qualified -> Ordering
$ccompare :: Qualified -> Qualified -> Ordering
Ord)
synth :: Qualified -> SynthName
synth :: Qualified -> SynthName
synth (Qualified SynthName
synth SynthName
_) = SynthName
synth
name :: Qualified -> Name
name :: Qualified -> SynthName
name (Qualified SynthName
_ SynthName
name) = SynthName
name
instance Pretty Qualified where pretty :: Qualified -> SynthName
pretty = Qualified -> SynthName
show_qualified
instance Serialize.Serialize Qualified where
put :: Putter Qualified
put (Qualified SynthName
a SynthName
b) = forall a. Serialize a => Putter a
Serialize.put SynthName
a forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall a. Serialize a => Putter a
Serialize.put SynthName
b
get :: Get Qualified
get = SynthName -> SynthName -> Qualified
Qualified forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Serialize a => Get a
Serialize.get forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a. Serialize a => Get a
Serialize.get
type SynthName = Text
type Name = Text
parse_qualified :: Text -> Qualified
parse_qualified :: SynthName -> Qualified
parse_qualified SynthName
text = SynthName -> SynthName -> Qualified
Qualified SynthName
pre (Int -> SynthName -> SynthName
Text.drop Int
1 SynthName
post)
where (SynthName
pre, SynthName
post) = (Char -> Bool) -> SynthName -> (SynthName, SynthName)
Text.break (forall a. Eq a => a -> a -> Bool
==Char
'/') SynthName
text
show_qualified :: Qualified -> Text
show_qualified :: Qualified -> SynthName
show_qualified (Qualified SynthName
synth SynthName
name) = SynthName
synth forall a. Semigroup a => a -> a -> a
<> SynthName
"/" forall a. Semigroup a => a -> a -> a
<> SynthName
name
dummy :: Qualified
dummy :: Qualified
dummy = SynthName -> SynthName -> Qualified
Qualified SynthName
"dummy" SynthName
""