{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
module Solkattu.Solkattu where
import qualified Control.Exception as Exception
import qualified Control.Monad.State.Strict as State
import qualified Data.List as List
import qualified Data.Text as Text
import qualified Util.CallStack as CallStack
import qualified Util.Num as Num
import qualified Util.Lists as Lists
import qualified Util.Styled as Styled
import qualified Derive.Expr as Expr
import qualified Solkattu.S as S
import qualified Solkattu.Tala as Tala
import Global
class (Show a, Pretty a) => Notation a where
notation :: a -> (Styled.Style, Text)
extension :: a -> Char
extension a
_ = Char
' '
textNotation :: Text -> (Styled.Style, Text)
textNotation :: Text -> (Style, Text)
textNotation = (forall a. Monoid a => a
mempty,)
notationText :: Notation a => a -> Text
notationText :: forall a. Notation a => a -> Text
notationText = forall a b. (a, b) -> b
snd forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Notation a => a -> (Style, Text)
notation
type Error = Text
data Note sollu =
Note (NoteT sollu)
| Space !Space
| Pattern !Pattern
| Alignment !Tala.Akshara
deriving (Note sollu -> Note sollu -> Bool
forall sollu. Eq sollu => Note sollu -> Note sollu -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Note sollu -> Note sollu -> Bool
$c/= :: forall sollu. Eq sollu => Note sollu -> Note sollu -> Bool
== :: Note sollu -> Note sollu -> Bool
$c== :: forall sollu. Eq sollu => Note sollu -> Note sollu -> Bool
Eq, Note sollu -> Note sollu -> Ordering
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
forall {sollu}. Ord sollu => Eq (Note sollu)
forall sollu. Ord sollu => Note sollu -> Note sollu -> Bool
forall sollu. Ord sollu => Note sollu -> Note sollu -> Ordering
forall sollu. Ord sollu => Note sollu -> Note sollu -> Note sollu
min :: Note sollu -> Note sollu -> Note sollu
$cmin :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Note sollu
max :: Note sollu -> Note sollu -> Note sollu
$cmax :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Note sollu
>= :: Note sollu -> Note sollu -> Bool
$c>= :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Bool
> :: Note sollu -> Note sollu -> Bool
$c> :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Bool
<= :: Note sollu -> Note sollu -> Bool
$c<= :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Bool
< :: Note sollu -> Note sollu -> Bool
$c< :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Bool
compare :: Note sollu -> Note sollu -> Ordering
$ccompare :: forall sollu. Ord sollu => Note sollu -> Note sollu -> Ordering
Ord, Int -> Note sollu -> ShowS
forall sollu. Show sollu => Int -> Note sollu -> ShowS
forall sollu. Show sollu => [Note sollu] -> ShowS
forall sollu. Show sollu => Note sollu -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Note sollu] -> ShowS
$cshowList :: forall sollu. Show sollu => [Note sollu] -> ShowS
show :: Note sollu -> String
$cshow :: forall sollu. Show sollu => Note sollu -> String
showsPrec :: Int -> Note sollu -> ShowS
$cshowsPrec :: forall sollu. Show sollu => Int -> Note sollu -> ShowS
Show, forall a b. a -> Note b -> Note a
forall a b. (a -> b) -> Note a -> Note b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Note b -> Note a
$c<$ :: forall a b. a -> Note b -> Note a
fmap :: forall a b. (a -> b) -> Note a -> Note b
$cfmap :: forall a b. (a -> b) -> Note a -> Note b
Functor, forall a. Eq a => a -> Note a -> Bool
forall a. Num a => Note a -> a
forall a. Ord a => Note a -> a
forall m. Monoid m => Note m -> m
forall a. Note a -> Bool
forall a. Note a -> Int
forall a. Note a -> [a]
forall a. (a -> a -> a) -> Note a -> a
forall m a. Monoid m => (a -> m) -> Note a -> m
forall b a. (b -> a -> b) -> b -> Note a -> b
forall a b. (a -> b -> b) -> b -> Note a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Note a -> a
$cproduct :: forall a. Num a => Note a -> a
sum :: forall a. Num a => Note a -> a
$csum :: forall a. Num a => Note a -> a
minimum :: forall a. Ord a => Note a -> a
$cminimum :: forall a. Ord a => Note a -> a
maximum :: forall a. Ord a => Note a -> a
$cmaximum :: forall a. Ord a => Note a -> a
elem :: forall a. Eq a => a -> Note a -> Bool
$celem :: forall a. Eq a => a -> Note a -> Bool
length :: forall a. Note a -> Int
$clength :: forall a. Note a -> Int
null :: forall a. Note a -> Bool
$cnull :: forall a. Note a -> Bool
toList :: forall a. Note a -> [a]
$ctoList :: forall a. Note a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Note a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Note a -> a
foldr1 :: forall a. (a -> a -> a) -> Note a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Note a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Note a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Note a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Note a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Note a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Note a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Note a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Note a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Note a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Note a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Note a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Note a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Note a -> m
fold :: forall m. Monoid m => Note m -> m
$cfold :: forall m. Monoid m => Note m -> m
Foldable, Functor Note
Foldable Note
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Note (m a) -> m (Note a)
forall (f :: * -> *) a. Applicative f => Note (f a) -> f (Note a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Note a -> m (Note b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Note a -> f (Note b)
sequence :: forall (m :: * -> *) a. Monad m => Note (m a) -> m (Note a)
$csequence :: forall (m :: * -> *) a. Monad m => Note (m a) -> m (Note a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Note a -> m (Note b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Note a -> m (Note b)
sequenceA :: forall (f :: * -> *) a. Applicative f => Note (f a) -> f (Note a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Note (f a) -> f (Note a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Note a -> f (Note b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Note a -> f (Note b)
Traversable)
instance Pretty sollu => Pretty (Note sollu) where
pretty :: Note sollu -> Text
pretty Note sollu
n = case Note sollu
n of
Note NoteT sollu
note -> forall a. Pretty a => a -> Text
pretty NoteT sollu
note
Space Space
space -> forall a. Pretty a => a -> Text
pretty Space
space
Pattern Pattern
p -> forall a. Pretty a => a -> Text
pretty Pattern
p
Alignment Int
n -> Text
"@" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
n
data Group = GReduction !Reduction | GMeta !Meta
deriving (Group -> Group -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Group -> Group -> Bool
$c/= :: Group -> Group -> Bool
== :: Group -> Group -> Bool
$c== :: Group -> Group -> Bool
Eq, Eq Group
Group -> Group -> Bool
Group -> Group -> Ordering
Group -> Group -> Group
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 :: Group -> Group -> Group
$cmin :: Group -> Group -> Group
max :: Group -> Group -> Group
$cmax :: Group -> Group -> Group
>= :: Group -> Group -> Bool
$c>= :: Group -> Group -> Bool
> :: Group -> Group -> Bool
$c> :: Group -> Group -> Bool
<= :: Group -> Group -> Bool
$c<= :: Group -> Group -> Bool
< :: Group -> Group -> Bool
$c< :: Group -> Group -> Bool
compare :: Group -> Group -> Ordering
$ccompare :: Group -> Group -> Ordering
Ord, Int -> Group -> ShowS
[Group] -> ShowS
Group -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Group] -> ShowS
$cshowList :: [Group] -> ShowS
show :: Group -> String
$cshow :: Group -> String
showsPrec :: Int -> Group -> ShowS
$cshowsPrec :: Int -> Group -> ShowS
Show)
data Reduction = Reduction {
Reduction -> FMatra
_split :: !S.FMatra
, Reduction -> Side
_side :: !Side
} deriving (Reduction -> Reduction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reduction -> Reduction -> Bool
$c/= :: Reduction -> Reduction -> Bool
== :: Reduction -> Reduction -> Bool
$c== :: Reduction -> Reduction -> Bool
Eq, Eq Reduction
Reduction -> Reduction -> Bool
Reduction -> Reduction -> Ordering
Reduction -> Reduction -> Reduction
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 :: Reduction -> Reduction -> Reduction
$cmin :: Reduction -> Reduction -> Reduction
max :: Reduction -> Reduction -> Reduction
$cmax :: Reduction -> Reduction -> Reduction
>= :: Reduction -> Reduction -> Bool
$c>= :: Reduction -> Reduction -> Bool
> :: Reduction -> Reduction -> Bool
$c> :: Reduction -> Reduction -> Bool
<= :: Reduction -> Reduction -> Bool
$c<= :: Reduction -> Reduction -> Bool
< :: Reduction -> Reduction -> Bool
$c< :: Reduction -> Reduction -> Bool
compare :: Reduction -> Reduction -> Ordering
$ccompare :: Reduction -> Reduction -> Ordering
Ord, Int -> Reduction -> ShowS
[Reduction] -> ShowS
Reduction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reduction] -> ShowS
$cshowList :: [Reduction] -> ShowS
show :: Reduction -> String
$cshow :: Reduction -> String
showsPrec :: Int -> Reduction -> ShowS
$cshowsPrec :: Int -> Reduction -> ShowS
Show)
data Meta = Meta {
Meta -> Maybe Int
_matras :: !(Maybe S.Matra)
, Meta -> Maybe Text
_name :: !(Maybe Text)
, Meta -> GroupType
_type :: !GroupType
} deriving (Meta -> Meta -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Meta -> Meta -> Bool
$c/= :: Meta -> Meta -> Bool
== :: Meta -> Meta -> Bool
$c== :: Meta -> Meta -> Bool
Eq, Eq Meta
Meta -> Meta -> Bool
Meta -> Meta -> Ordering
Meta -> Meta -> Meta
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 :: Meta -> Meta -> Meta
$cmin :: Meta -> Meta -> Meta
max :: Meta -> Meta -> Meta
$cmax :: Meta -> Meta -> Meta
>= :: Meta -> Meta -> Bool
$c>= :: Meta -> Meta -> Bool
> :: Meta -> Meta -> Bool
$c> :: Meta -> Meta -> Bool
<= :: Meta -> Meta -> Bool
$c<= :: Meta -> Meta -> Bool
< :: Meta -> Meta -> Bool
$c< :: Meta -> Meta -> Bool
compare :: Meta -> Meta -> Ordering
$ccompare :: Meta -> Meta -> Ordering
Ord, Int -> Meta -> ShowS
[Meta] -> ShowS
Meta -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Meta] -> ShowS
$cshowList :: [Meta] -> ShowS
show :: Meta -> String
$cshow :: Meta -> String
showsPrec :: Int -> Meta -> ShowS
$cshowsPrec :: Int -> Meta -> ShowS
Show)
meta :: GroupType -> Meta
meta :: GroupType -> Meta
meta = Maybe Int -> Maybe Text -> GroupType -> Meta
Meta forall a. Maybe a
Nothing forall a. Maybe a
Nothing
data GroupType =
GGroup
| GReductionT
| GFiller
| GPattern
| GExplicitPattern
| GSarva
| GCheckDuration !S.Duration
deriving (GroupType -> GroupType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupType -> GroupType -> Bool
$c/= :: GroupType -> GroupType -> Bool
== :: GroupType -> GroupType -> Bool
$c== :: GroupType -> GroupType -> Bool
Eq, Eq GroupType
GroupType -> GroupType -> Bool
GroupType -> GroupType -> Ordering
GroupType -> GroupType -> GroupType
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 :: GroupType -> GroupType -> GroupType
$cmin :: GroupType -> GroupType -> GroupType
max :: GroupType -> GroupType -> GroupType
$cmax :: GroupType -> GroupType -> GroupType
>= :: GroupType -> GroupType -> Bool
$c>= :: GroupType -> GroupType -> Bool
> :: GroupType -> GroupType -> Bool
$c> :: GroupType -> GroupType -> Bool
<= :: GroupType -> GroupType -> Bool
$c<= :: GroupType -> GroupType -> Bool
< :: GroupType -> GroupType -> Bool
$c< :: GroupType -> GroupType -> Bool
compare :: GroupType -> GroupType -> Ordering
$ccompare :: GroupType -> GroupType -> Ordering
Ord, Int -> GroupType -> ShowS
[GroupType] -> ShowS
GroupType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupType] -> ShowS
$cshowList :: [GroupType] -> ShowS
show :: GroupType -> String
$cshow :: GroupType -> String
showsPrec :: Int -> GroupType -> ShowS
$cshowsPrec :: Int -> GroupType -> ShowS
Show)
groupTypes :: [GroupType]
groupTypes :: [GroupType]
groupTypes = [GroupType
GGroup, GroupType
GReductionT, GroupType
GFiller, GroupType
GPattern, GroupType
GExplicitPattern, GroupType
GSarva]
instance Pretty GroupType where pretty :: GroupType -> Text
pretty = forall a. Show a => a -> Text
showt
data Side = Before | After deriving (Side -> Side -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Side -> Side -> Bool
$c/= :: Side -> Side -> Bool
== :: Side -> Side -> Bool
$c== :: Side -> Side -> Bool
Eq, Eq Side
Side -> Side -> Bool
Side -> Side -> Ordering
Side -> Side -> Side
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 :: Side -> Side -> Side
$cmin :: Side -> Side -> Side
max :: Side -> Side -> Side
$cmax :: Side -> Side -> Side
>= :: Side -> Side -> Bool
$c>= :: Side -> Side -> Bool
> :: Side -> Side -> Bool
$c> :: Side -> Side -> Bool
<= :: Side -> Side -> Bool
$c<= :: Side -> Side -> Bool
< :: Side -> Side -> Bool
$c< :: Side -> Side -> Bool
compare :: Side -> Side -> Ordering
$ccompare :: Side -> Side -> Ordering
Ord, Int -> Side -> ShowS
[Side] -> ShowS
Side -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Side] -> ShowS
$cshowList :: [Side] -> ShowS
show :: Side -> String
$cshow :: Side -> String
showsPrec :: Int -> Side -> ShowS
$cshowsPrec :: Int -> Side -> ShowS
Show)
instance Pretty Side where pretty :: Side -> Text
pretty = forall a. Show a => a -> Text
showt
instance Pretty Group where
pretty :: Group -> Text
pretty (GReduction Reduction
r) = forall a. Pretty a => a -> Text
pretty Reduction
r
pretty (GMeta Meta
m) = forall a. Pretty a => a -> Text
pretty Meta
m
instance Pretty Reduction where
pretty :: Reduction -> Text
pretty (Reduction FMatra
split Side
side) = forall a. Pretty a => a -> Text
pretty (FMatra
split, Side
side)
instance Pretty Meta where
pretty :: Meta -> Text
pretty (Meta (Just Int
matras) Maybe Text
Nothing GroupType
GSarva) = Text
"==" forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Int
matras
pretty (Meta Maybe Int
Nothing Maybe Text
Nothing GroupType
gtype) = forall a. Pretty a => a -> Text
pretty GroupType
gtype
pretty (Meta Maybe Int
matras Maybe Text
name GroupType
gtype) = forall a. Pretty a => a -> Text
pretty (Maybe Int
matras, Maybe Text
name, GroupType
gtype)
data Space = Rest
| Offset
deriving (Space -> Space -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Space -> Space -> Bool
$c/= :: Space -> Space -> Bool
== :: Space -> Space -> Bool
$c== :: Space -> Space -> Bool
Eq, Eq Space
Space -> Space -> Bool
Space -> Space -> Ordering
Space -> Space -> Space
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 :: Space -> Space -> Space
$cmin :: Space -> Space -> Space
max :: Space -> Space -> Space
$cmax :: Space -> Space -> Space
>= :: Space -> Space -> Bool
$c>= :: Space -> Space -> Bool
> :: Space -> Space -> Bool
$c> :: Space -> Space -> Bool
<= :: Space -> Space -> Bool
$c<= :: Space -> Space -> Bool
< :: Space -> Space -> Bool
$c< :: Space -> Space -> Bool
compare :: Space -> Space -> Ordering
$ccompare :: Space -> Space -> Ordering
Ord, Int -> Space -> ShowS
[Space] -> ShowS
Space -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Space] -> ShowS
$cshowList :: [Space] -> ShowS
show :: Space -> String
$cshow :: Space -> String
showsPrec :: Int -> Space -> ShowS
$cshowsPrec :: Int -> Space -> ShowS
Show)
instance Pretty Space where
pretty :: Space -> Text
pretty Space
Rest = Text
"__"
pretty Space
Offset = Text
".."
data NoteT sollu = NoteT {
forall sollu. NoteT sollu -> sollu
_sollu :: !sollu
, forall sollu. NoteT sollu -> Bool
_karvai :: !Bool
, forall sollu. NoteT sollu -> Maybe Tag
_tag :: !(Maybe Tag)
} deriving (NoteT sollu -> NoteT sollu -> Bool
forall sollu. Eq sollu => NoteT sollu -> NoteT sollu -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NoteT sollu -> NoteT sollu -> Bool
$c/= :: forall sollu. Eq sollu => NoteT sollu -> NoteT sollu -> Bool
== :: NoteT sollu -> NoteT sollu -> Bool
$c== :: forall sollu. Eq sollu => NoteT sollu -> NoteT sollu -> Bool
Eq, NoteT sollu -> NoteT sollu -> Bool
NoteT sollu -> NoteT sollu -> Ordering
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
forall {sollu}. Ord sollu => Eq (NoteT sollu)
forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Bool
forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Ordering
forall sollu.
Ord sollu =>
NoteT sollu -> NoteT sollu -> NoteT sollu
min :: NoteT sollu -> NoteT sollu -> NoteT sollu
$cmin :: forall sollu.
Ord sollu =>
NoteT sollu -> NoteT sollu -> NoteT sollu
max :: NoteT sollu -> NoteT sollu -> NoteT sollu
$cmax :: forall sollu.
Ord sollu =>
NoteT sollu -> NoteT sollu -> NoteT sollu
>= :: NoteT sollu -> NoteT sollu -> Bool
$c>= :: forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Bool
> :: NoteT sollu -> NoteT sollu -> Bool
$c> :: forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Bool
<= :: NoteT sollu -> NoteT sollu -> Bool
$c<= :: forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Bool
< :: NoteT sollu -> NoteT sollu -> Bool
$c< :: forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Bool
compare :: NoteT sollu -> NoteT sollu -> Ordering
$ccompare :: forall sollu. Ord sollu => NoteT sollu -> NoteT sollu -> Ordering
Ord, Int -> NoteT sollu -> ShowS
forall sollu. Show sollu => Int -> NoteT sollu -> ShowS
forall sollu. Show sollu => [NoteT sollu] -> ShowS
forall sollu. Show sollu => NoteT sollu -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NoteT sollu] -> ShowS
$cshowList :: forall sollu. Show sollu => [NoteT sollu] -> ShowS
show :: NoteT sollu -> String
$cshow :: forall sollu. Show sollu => NoteT sollu -> String
showsPrec :: Int -> NoteT sollu -> ShowS
$cshowsPrec :: forall sollu. Show sollu => Int -> NoteT sollu -> ShowS
Show, forall a b. a -> NoteT b -> NoteT a
forall a b. (a -> b) -> NoteT a -> NoteT b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> NoteT b -> NoteT a
$c<$ :: forall a b. a -> NoteT b -> NoteT a
fmap :: forall a b. (a -> b) -> NoteT a -> NoteT b
$cfmap :: forall a b. (a -> b) -> NoteT a -> NoteT b
Functor, forall a. Eq a => a -> NoteT a -> Bool
forall a. Num a => NoteT a -> a
forall a. Ord a => NoteT a -> a
forall m. Monoid m => NoteT m -> m
forall sollu. NoteT sollu -> Bool
forall a. NoteT a -> Int
forall a. NoteT a -> [a]
forall a. (a -> a -> a) -> NoteT a -> a
forall m a. Monoid m => (a -> m) -> NoteT a -> m
forall b a. (b -> a -> b) -> b -> NoteT a -> b
forall a b. (a -> b -> b) -> b -> NoteT a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => NoteT a -> a
$cproduct :: forall a. Num a => NoteT a -> a
sum :: forall a. Num a => NoteT a -> a
$csum :: forall a. Num a => NoteT a -> a
minimum :: forall a. Ord a => NoteT a -> a
$cminimum :: forall a. Ord a => NoteT a -> a
maximum :: forall a. Ord a => NoteT a -> a
$cmaximum :: forall a. Ord a => NoteT a -> a
elem :: forall a. Eq a => a -> NoteT a -> Bool
$celem :: forall a. Eq a => a -> NoteT a -> Bool
length :: forall a. NoteT a -> Int
$clength :: forall a. NoteT a -> Int
null :: forall sollu. NoteT sollu -> Bool
$cnull :: forall sollu. NoteT sollu -> Bool
toList :: forall a. NoteT a -> [a]
$ctoList :: forall a. NoteT a -> [a]
foldl1 :: forall a. (a -> a -> a) -> NoteT a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> NoteT a -> a
foldr1 :: forall a. (a -> a -> a) -> NoteT a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> NoteT a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> NoteT a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> NoteT a -> b
foldl :: forall b a. (b -> a -> b) -> b -> NoteT a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> NoteT a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> NoteT a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> NoteT a -> b
foldr :: forall a b. (a -> b -> b) -> b -> NoteT a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> NoteT a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> NoteT a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> NoteT a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> NoteT a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> NoteT a -> m
fold :: forall m. Monoid m => NoteT m -> m
$cfold :: forall m. Monoid m => NoteT m -> m
Foldable, Functor NoteT
Foldable NoteT
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => NoteT (m a) -> m (NoteT a)
forall (f :: * -> *) a. Applicative f => NoteT (f a) -> f (NoteT a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NoteT a -> m (NoteT b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NoteT a -> f (NoteT b)
sequence :: forall (m :: * -> *) a. Monad m => NoteT (m a) -> m (NoteT a)
$csequence :: forall (m :: * -> *) a. Monad m => NoteT (m a) -> m (NoteT a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NoteT a -> m (NoteT b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NoteT a -> m (NoteT b)
sequenceA :: forall (f :: * -> *) a. Applicative f => NoteT (f a) -> f (NoteT a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => NoteT (f a) -> f (NoteT a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NoteT a -> f (NoteT b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NoteT a -> f (NoteT b)
Traversable)
data Tag = Tag !Int
| Middle
| Standard
deriving (Tag -> Tag -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tag -> Tag -> Bool
$c/= :: Tag -> Tag -> Bool
== :: Tag -> Tag -> Bool
$c== :: Tag -> Tag -> Bool
Eq, Eq Tag
Tag -> Tag -> Bool
Tag -> Tag -> Ordering
Tag -> Tag -> Tag
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 :: Tag -> Tag -> Tag
$cmin :: Tag -> Tag -> Tag
max :: Tag -> Tag -> Tag
$cmax :: Tag -> Tag -> Tag
>= :: Tag -> Tag -> Bool
$c>= :: Tag -> Tag -> Bool
> :: Tag -> Tag -> Bool
$c> :: Tag -> Tag -> Bool
<= :: Tag -> Tag -> Bool
$c<= :: Tag -> Tag -> Bool
< :: Tag -> Tag -> Bool
$c< :: Tag -> Tag -> Bool
compare :: Tag -> Tag -> Ordering
$ccompare :: Tag -> Tag -> Ordering
Ord, Int -> Tag -> ShowS
[Tag] -> ShowS
Tag -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tag] -> ShowS
$cshowList :: [Tag] -> ShowS
show :: Tag -> String
$cshow :: Tag -> String
showsPrec :: Int -> Tag -> ShowS
$cshowsPrec :: Int -> Tag -> ShowS
Show)
instance Pretty Tag where
pretty :: Tag -> Text
pretty (Tag Int
i) = forall a. Pretty a => a -> Text
pretty Int
i
pretty Tag
Middle = Text
"mid"
pretty Tag
Standard = Text
"standard"
instance Num Tag where
fromInteger :: Integer -> Tag
fromInteger = Int -> Tag
Tag forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => Integer -> a
fromInteger
+ :: Tag -> Tag -> Tag
(+) = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
(-) = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
* :: Tag -> Tag -> Tag
(*) = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
negate :: Tag -> Tag
negate = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
abs :: Tag -> Tag
abs = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
signum :: Tag -> Tag
signum = forall a. HasCallStack => String -> a
error String
"tags aren't numbers"
note :: sollu -> NoteT sollu
note :: forall sollu. sollu -> NoteT sollu
note sollu
sollu = NoteT { _sollu :: sollu
_sollu = sollu
sollu, _karvai :: Bool
_karvai = Bool
False, _tag :: Maybe Tag
_tag = forall a. Maybe a
Nothing }
noteOf :: Note sollu -> Maybe (NoteT sollu)
noteOf :: forall sollu. Note sollu -> Maybe (NoteT sollu)
noteOf (Note NoteT sollu
n) = forall a. a -> Maybe a
Just NoteT sollu
n
noteOf Note sollu
_ = forall a. Maybe a
Nothing
solluOf :: Note sollu -> Maybe sollu
solluOf :: forall sollu. Note sollu -> Maybe sollu
solluOf = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall sollu. NoteT sollu -> sollu
_sollu forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall sollu. Note sollu -> Maybe (NoteT sollu)
noteOf
instance Pretty sollu => Pretty (NoteT sollu) where
pretty :: NoteT sollu -> Text
pretty (NoteT sollu
sollu Bool
karvai Maybe Tag
tag) = forall a. Monoid a => [a] -> a
mconcat
[ Maybe Tag -> Text
prettyTag Maybe Tag
tag
, forall a. Pretty a => a -> Text
pretty sollu
sollu
, forall {a}. IsString a => Bool -> a
prettyKarvai Bool
karvai
]
where
prettyKarvai :: Bool -> a
prettyKarvai Bool
k = if Bool
k then a
"(k)" else a
""
prettyTag :: Maybe Tag -> Text
prettyTag = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" ((forall a. Semigroup a => a -> a -> a
<>Text
"^") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Pretty a => a -> Text
pretty)
modifyNote :: (NoteT a -> NoteT b) -> Note a -> Note b
modifyNote :: forall a b. (NoteT a -> NoteT b) -> Note a -> Note b
modifyNote NoteT a -> NoteT b
f Note a
n = case Note a
n of
Note NoteT a
note -> forall sollu. NoteT sollu -> Note sollu
Note (NoteT a -> NoteT b
f NoteT a
note)
Space Space
space -> forall sollu. Space -> Note sollu
Space Space
space
Pattern Pattern
p -> forall sollu. Pattern -> Note sollu
Pattern Pattern
p
Alignment Int
n -> forall sollu. Int -> Note sollu
Alignment Int
n
instance S.HasMatras (Note sollu) where
matrasOf :: Note sollu -> Int
matrasOf Note sollu
n = case Note sollu
n of
Note NoteT sollu
note -> if forall sollu. NoteT sollu -> Bool
_karvai NoteT sollu
note then Int
0 else Int
1
Space {} -> Int
1
Pattern Pattern
p -> forall a. HasMatras a => a -> Int
S.matrasOf Pattern
p
Alignment {} -> Int
0
hasSustain :: Note sollu -> Bool
hasSustain Note sollu
n = case Note sollu
n of
Note {} -> Bool
False
Space {} -> Bool
True
Pattern {} -> Bool
True
Alignment {} -> Bool
False
newtype Pattern = PatternM S.Matra
deriving (Pattern -> Pattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern -> Pattern -> Bool
$c/= :: Pattern -> Pattern -> Bool
== :: Pattern -> Pattern -> Bool
$c== :: Pattern -> Pattern -> Bool
Eq, Eq Pattern
Pattern -> Pattern -> Bool
Pattern -> Pattern -> Ordering
Pattern -> Pattern -> Pattern
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 :: Pattern -> Pattern -> Pattern
$cmin :: Pattern -> Pattern -> Pattern
max :: Pattern -> Pattern -> Pattern
$cmax :: Pattern -> Pattern -> Pattern
>= :: Pattern -> Pattern -> Bool
$c>= :: Pattern -> Pattern -> Bool
> :: Pattern -> Pattern -> Bool
$c> :: Pattern -> Pattern -> Bool
<= :: Pattern -> Pattern -> Bool
$c<= :: Pattern -> Pattern -> Bool
< :: Pattern -> Pattern -> Bool
$c< :: Pattern -> Pattern -> Bool
compare :: Pattern -> Pattern -> Ordering
$ccompare :: Pattern -> Pattern -> Ordering
Ord, Int -> Pattern -> ShowS
[Pattern] -> ShowS
Pattern -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pattern] -> ShowS
$cshowList :: [Pattern] -> ShowS
show :: Pattern -> String
$cshow :: Pattern -> String
showsPrec :: Int -> Pattern -> ShowS
$cshowsPrec :: Int -> Pattern -> ShowS
Show)
pattern :: S.Matra -> Pattern
pattern :: Int -> Pattern
pattern = Int -> Pattern
PatternM
instance S.HasMatras Pattern where
matrasOf :: Pattern -> Int
matrasOf (PatternM Int
m) = Int
m
hasSustain :: Pattern -> Bool
hasSustain Pattern
_ = Bool
True
instance Pretty Pattern where pretty :: Pattern -> Text
pretty = forall a. Notation a => a -> Text
notationText
instance Notation Pattern where
notation :: Pattern -> (Style, Text)
notation (PatternM Int
matras) = Text -> (Style, Text)
textNotation forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> Text
showt Int
matras forall a. Semigroup a => a -> a -> a
<> Text
"p"
extension :: Pattern -> Char
extension Pattern
_ = Char
'-'
instance Expr.ToExpr Pattern where
to_expr :: Pattern -> Expr MiniVal
to_expr Pattern
p = case Pattern
p of
PatternM Int
matras -> forall val. Call val -> Expr val
Expr.generator forall a b. (a -> b) -> a -> b
$
forall val. Symbol -> [val] -> Call val
Expr.call Symbol
"p" [forall a. ToVal a => a -> MiniVal
Expr.to_val Int
matras]
data Karvai = Karvai | NotKarvai deriving (Karvai -> Karvai -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Karvai -> Karvai -> Bool
$c/= :: Karvai -> Karvai -> Bool
== :: Karvai -> Karvai -> Bool
$c== :: Karvai -> Karvai -> Bool
Eq, Eq Karvai
Karvai -> Karvai -> Bool
Karvai -> Karvai -> Ordering
Karvai -> Karvai -> Karvai
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 :: Karvai -> Karvai -> Karvai
$cmin :: Karvai -> Karvai -> Karvai
max :: Karvai -> Karvai -> Karvai
$cmax :: Karvai -> Karvai -> Karvai
>= :: Karvai -> Karvai -> Bool
$c>= :: Karvai -> Karvai -> Bool
> :: Karvai -> Karvai -> Bool
$c> :: Karvai -> Karvai -> Bool
<= :: Karvai -> Karvai -> Bool
$c<= :: Karvai -> Karvai -> Bool
< :: Karvai -> Karvai -> Bool
$c< :: Karvai -> Karvai -> Bool
compare :: Karvai -> Karvai -> Ordering
$ccompare :: Karvai -> Karvai -> Ordering
Ord, Int -> Karvai -> ShowS
[Karvai] -> ShowS
Karvai -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Karvai] -> ShowS
$cshowList :: [Karvai] -> ShowS
show :: Karvai -> String
$cshow :: Karvai -> String
showsPrec :: Int -> Karvai -> ShowS
$cshowsPrec :: Int -> Karvai -> ShowS
Show)
data Sollu =
NoSollu
| Cham | Dheem | Dhom | Di | Dim | Din | Dit | Du
| Ga | Gin | Gu | Jo | Ka | Ki | Ku | Kum | Lang
| Mi | Na | Nam | Nang | Nu | Ri
| Ta | Tam | Tang | Tong | Tat | Tha | Thom | Ti
deriving (Sollu -> Sollu -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sollu -> Sollu -> Bool
$c/= :: Sollu -> Sollu -> Bool
== :: Sollu -> Sollu -> Bool
$c== :: Sollu -> Sollu -> Bool
Eq, Eq Sollu
Sollu -> Sollu -> Bool
Sollu -> Sollu -> Ordering
Sollu -> Sollu -> Sollu
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 :: Sollu -> Sollu -> Sollu
$cmin :: Sollu -> Sollu -> Sollu
max :: Sollu -> Sollu -> Sollu
$cmax :: Sollu -> Sollu -> Sollu
>= :: Sollu -> Sollu -> Bool
$c>= :: Sollu -> Sollu -> Bool
> :: Sollu -> Sollu -> Bool
$c> :: Sollu -> Sollu -> Bool
<= :: Sollu -> Sollu -> Bool
$c<= :: Sollu -> Sollu -> Bool
< :: Sollu -> Sollu -> Bool
$c< :: Sollu -> Sollu -> Bool
compare :: Sollu -> Sollu -> Ordering
$ccompare :: Sollu -> Sollu -> Ordering
Ord, Int -> Sollu
Sollu -> Int
Sollu -> [Sollu]
Sollu -> Sollu
Sollu -> Sollu -> [Sollu]
Sollu -> Sollu -> Sollu -> [Sollu]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Sollu -> Sollu -> Sollu -> [Sollu]
$cenumFromThenTo :: Sollu -> Sollu -> Sollu -> [Sollu]
enumFromTo :: Sollu -> Sollu -> [Sollu]
$cenumFromTo :: Sollu -> Sollu -> [Sollu]
enumFromThen :: Sollu -> Sollu -> [Sollu]
$cenumFromThen :: Sollu -> Sollu -> [Sollu]
enumFrom :: Sollu -> [Sollu]
$cenumFrom :: Sollu -> [Sollu]
fromEnum :: Sollu -> Int
$cfromEnum :: Sollu -> Int
toEnum :: Int -> Sollu
$ctoEnum :: Int -> Sollu
pred :: Sollu -> Sollu
$cpred :: Sollu -> Sollu
succ :: Sollu -> Sollu
$csucc :: Sollu -> Sollu
Enum, Sollu
forall a. a -> a -> Bounded a
maxBound :: Sollu
$cmaxBound :: Sollu
minBound :: Sollu
$cminBound :: Sollu
Bounded, Int -> Sollu -> ShowS
[Sollu] -> ShowS
Sollu -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sollu] -> ShowS
$cshowList :: [Sollu] -> ShowS
show :: Sollu -> String
$cshow :: Sollu -> String
showsPrec :: Int -> Sollu -> ShowS
$cshowsPrec :: Int -> Sollu -> ShowS
Show)
instance Notation Sollu where notation :: Sollu -> (Style, Text)
notation = Text -> (Style, Text)
textNotation forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
Text.toLower forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> Text
showt
instance Pretty Sollu where pretty :: Sollu -> Text
pretty = forall a. Notation a => a -> Text
notationText
parseSollus :: Text -> Either Error [Maybe Sollu]
parseSollus :: Text -> Either Text [Maybe Sollu]
parseSollus = forall sollu.
Show sollu =>
[(Text, sollu)] -> Text -> Either Text [Maybe sollu]
parseSyllables [(Text, Sollu)]
allSollus
allSollus :: [(Text, Sollu)]
allSollus :: [(Text, Sollu)]
allSollus = forall a k. (a -> k) -> [a] -> [(k, a)]
Lists.keyOn forall a. Notation a => a -> Text
notationText forall a b. (a -> b) -> a -> b
$ forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/= Sollu
NoSollu) [forall a. Bounded a => a
minBound ..]
parseSyllables :: Show sollu => [(Text, sollu)] -> Text
-> Either Error [Maybe sollu]
parseSyllables :: forall sollu.
Show sollu =>
[(Text, sollu)] -> Text -> Either Text [Maybe sollu]
parseSyllables [(Text, sollu)]
solluMap = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Text -> Either Text [Maybe sollu]
parse forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
Text.words
where
parse :: Text -> Either Text [Maybe sollu]
parse Text
w = case forall sollu. [(Text, sollu)] -> Text -> [[Maybe sollu]]
parseSyllablesWord [(Text, sollu)]
solluMap Text
w of
[] -> forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Text
"no parse for " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Text
w
[[Maybe sollu]
sollus] -> forall a b. b -> Either a b
Right [Maybe sollu]
sollus
[[Maybe sollu]]
xs -> forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ Text
"multiple parses for " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt Text
w forall a. Semigroup a => a -> a -> a
<> Text
": " forall a. Semigroup a => a -> a -> a
<> forall a. Show a => a -> Text
showt [[Maybe sollu]]
xs
parseSyllablesWord :: [(Text, sollu)] -> Text -> [[Maybe sollu]]
parseSyllablesWord :: forall sollu. [(Text, sollu)] -> Text -> [[Maybe sollu]]
parseSyllablesWord [(Text, sollu)]
solluMap = Text -> [[Maybe sollu]]
go
where
go :: Text -> [[Maybe sollu]]
go Text
prefix
| Text -> Bool
Text.null Text
prefix = [[]]
| Text -> Bool
has Text
"_" = forall a b. (a -> b) -> [a] -> [b]
map (forall a. Maybe a
Nothing :) (Text -> [[Maybe sollu]]
go (Int -> Text -> Text
Text.drop Int
1 Text
prefix))
| Bool
otherwise = do
(Text
str, sollu
sollu) <- forall a. (a -> Bool) -> [a] -> [a]
filter (Text -> Bool
has forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) [(Text, sollu)]
solluMap
let suffix :: Text
suffix = Int -> Text -> Text
Text.drop (Text -> Int
Text.length Text
str) Text
prefix
Text
suffix <- Text
suffix forall a. a -> [a] -> [a]
: if Text
"n" Text -> Text -> Bool
`Text.isSuffixOf` Text
str
then [Text
"n" forall a. Semigroup a => a -> a -> a
<> Text
suffix] else []
(forall a. a -> Maybe a
Just sollu
sollu :) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [[Maybe sollu]]
go Text
suffix
where has :: Text -> Bool
has = (Text -> Text -> Bool
`Text.isPrefixOf` Text
prefix)
durationOf :: S.HasMatras a => S.Tempo -> S.Sequence Group a
-> S.Duration
durationOf :: forall a. HasMatras a => Tempo -> Sequence Group a -> Duration
durationOf = forall a dur.
(HasMatras a, Num dur, Ord dur) =>
(Tempo -> Duration -> dur) -> Tempo -> Sequence Group a -> dur
_durationOf (\Tempo
_ -> forall a. a -> a
id)
matrasOf :: S.HasMatras a => S.Tempo -> S.Sequence Group a -> S.FMatra
matrasOf :: forall a. HasMatras a => Tempo -> Sequence Group a -> FMatra
matrasOf = forall a dur.
(HasMatras a, Num dur, Ord dur) =>
(Tempo -> Duration -> dur) -> Tempo -> Sequence Group a -> dur
_durationOf forall {a} {b}. (Real a, Fractional b) => Tempo -> a -> b
toMatras
where toMatras :: Tempo -> a -> b
toMatras Tempo
tempo a
dur = forall a b. (Real a, Fractional b) => a -> b
realToFrac forall a b. (a -> b) -> a -> b
$ a
dur forall a. Num a => a -> a -> a
* forall a b. (Integral a, Num b) => a -> b
fromIntegral (Tempo -> Int
S._nadai Tempo
tempo)
_durationOf :: (S.HasMatras a, Num dur, Ord dur)
=> (S.Tempo -> S.Duration -> dur) -> S.Tempo -> S.Sequence Group a -> dur
_durationOf :: forall a dur.
(HasMatras a, Num dur, Ord dur) =>
(Tempo -> Duration -> dur) -> Tempo -> Sequence Group a -> dur
_durationOf Tempo -> Duration -> dur
convert Tempo
tempo = forall {a}. HasMatras a => Tempo -> [Note Group a] -> dur
go Tempo
tempo forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall g a. Sequence g a -> [Note g a]
S.toList
where
go :: Tempo -> [Note Group a] -> dur
go Tempo
tempo = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
Num.sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (Tempo -> Note Group a -> dur
get Tempo
tempo)
get :: Tempo -> Note Group a -> dur
get Tempo
tempo = \case
S.Note a
n -> Tempo -> Duration -> dur
convert Tempo
tempo forall a b. (a -> b) -> a -> b
$ forall a. HasMatras a => Tempo -> a -> Duration
S.noteDuration Tempo
tempo a
n
S.TempoChange TempoChange
change [Note Group a]
notes -> Tempo -> [Note Group a] -> dur
go (TempoChange -> Tempo -> Tempo
S.changeTempo TempoChange
change Tempo
tempo) [Note Group a]
notes
S.Group (GReduction (Reduction FMatra
splitAt Side
side)) [Note Group a]
notes -> case Side
side of
Side
Before -> forall a. Ord a => a -> a -> a
max dur
0 (Tempo -> [Note Group a] -> dur
go Tempo
tempo [Note Group a]
notes forall a. Num a => a -> a -> a
- dur
split)
Side
After -> forall a. Ord a => a -> a -> a
min dur
split (Tempo -> [Note Group a] -> dur
go Tempo
tempo [Note Group a]
notes)
where split :: dur
split = Tempo -> Duration -> dur
convert Tempo
tempo forall a b. (a -> b) -> a -> b
$ Tempo -> FMatra -> Duration
S.fmatraDuration Tempo
tempo FMatra
splitAt
S.Group (GMeta (Meta (Just Int
matras) Maybe Text
_ GroupType
_)) [Note Group a]
_notes ->
Tempo -> Duration -> dur
convert Tempo
tempo forall a b. (a -> b) -> a -> b
$ Tempo -> Duration
S.matraDuration Tempo
tempo forall a. Num a => a -> a -> a
* forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
matras
S.Group (GMeta (Meta Maybe Int
Nothing Maybe Text
_ GroupType
_)) [Note Group a]
notes -> Tempo -> [Note Group a] -> dur
go Tempo
tempo [Note Group a]
notes
flatDuration :: S.HasMatras a => S.Flat Group a -> S.Duration
flatDuration :: forall a. HasMatras a => Flat Group a -> Duration
flatDuration (S.FNote Tempo
tempo a
note) = forall a. HasMatras a => Tempo -> a -> Duration
S.noteDuration Tempo
tempo a
note
flatDuration (S.FGroup Tempo
tempo Group
group [Flat Group a]
notes) = case Group
group of
GReduction (Reduction FMatra
splitAt Side
side) -> case Side
side of
Side
Before -> forall a. Ord a => a -> a -> a
max Duration
0 (Duration
completeDur forall a. Num a => a -> a -> a
- Duration
split)
Side
After -> forall a. Ord a => a -> a -> a
min Duration
split Duration
completeDur
where
split :: Duration
split = Tempo -> FMatra -> Duration
S.fmatraDuration Tempo
tempo FMatra
splitAt
completeDur :: Duration
completeDur = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
Num.sum (forall a b. (a -> b) -> [a] -> [b]
map forall a. HasMatras a => Flat Group a -> Duration
flatDuration [Flat Group a]
notes)
GMeta (Meta (Just Int
matras) Maybe Text
_ GroupType
_) ->
Tempo -> Duration
S.matraDuration Tempo
tempo forall a. Num a => a -> a -> a
* forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
matras
GMeta (Meta Maybe Int
Nothing Maybe Text
_ GroupType
_) -> forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
Num.sum (forall a b. (a -> b) -> [a] -> [b]
map forall a. HasMatras a => Flat Group a -> Duration
flatDuration [Flat Group a]
notes)
cancelKarvai :: [S.Flat g (Note sollu)] -> [S.Flat g (Note sollu)]
cancelKarvai :: forall g sollu. [Flat g (Note sollu)] -> [Flat g (Note sollu)]
cancelKarvai [Flat g (Note sollu)]
ns = forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ forall s a. State s a -> s -> (a, s)
State.runState (forall {g} {sollu}.
[Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
ns []) Bool
False
where
go :: [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go (S.FGroup Tempo
tempo g
g [Flat g (Note sollu)]
children : [Flat g (Note sollu)]
notes) [Flat g (Note sollu)]
future = do
[Flat g (Note sollu)]
children <- [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
children ([Flat g (Note sollu)]
notes forall a. [a] -> [a] -> [a]
++ [Flat g (Note sollu)]
future)
(forall g a. Tempo -> g -> [Flat g a] -> Flat g a
S.FGroup Tempo
tempo g
g [Flat g (Note sollu)]
children :) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
notes [Flat g (Note sollu)]
future
go (S.FNote Tempo
tempo (Note NoteT sollu
note) : [Flat g (Note sollu)]
notes) [Flat g (Note sollu)]
future | forall sollu. NoteT sollu -> Bool
_karvai NoteT sollu
note =
if forall {sollu}. [Note sollu] -> Bool
nextRest (forall g a. [Flat g a] -> [a]
S.flattenedNotes ([Flat g (Note sollu)]
notes forall a. [a] -> [a] -> [a]
++ [Flat g (Note sollu)]
future))
then StateT Bool Identity ()
suppress
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (forall g a. Tempo -> a -> Flat g a
S.FNote Tempo
tempo (forall sollu. NoteT sollu -> Note sollu
Note (NoteT sollu
note { _karvai :: Bool
_karvai = Bool
False })) :)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
notes [Flat g (Note sollu)]
future
else [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
notes [Flat g (Note sollu)]
future
go (note :: Flat g (Note sollu)
note@(S.FNote Tempo
_ (Space Space
Rest)) : [Flat g (Note sollu)]
notes) [Flat g (Note sollu)]
future = forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM StateT Bool Identity Bool
isSuppressed
([Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
notes [Flat g (Note sollu)]
future) ((Flat g (Note sollu)
note:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
notes [Flat g (Note sollu)]
future)
go (Flat g (Note sollu)
n : [Flat g (Note sollu)]
ns) [Flat g (Note sollu)]
future = (Flat g (Note sollu)
n:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Flat g (Note sollu)]
-> [Flat g (Note sollu)]
-> StateT Bool Identity [Flat g (Note sollu)]
go [Flat g (Note sollu)]
ns [Flat g (Note sollu)]
future
go [] [Flat g (Note sollu)]
_ = forall (m :: * -> *) a. Monad m => a -> m a
return []
suppress :: StateT Bool Identity ()
suppress = forall s (m :: * -> *). MonadState s m => s -> m ()
State.put Bool
True
isSuppressed :: StateT Bool Identity Bool
isSuppressed = forall s (m :: * -> *). MonadState s m => m s
State.get forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall s (m :: * -> *). MonadState s m => s -> m ()
State.put Bool
False
nextRest :: [Note sollu] -> Bool
nextRest [] = Bool
False
nextRest (Note sollu
n : [Note sollu]
ns) = case Note sollu
n of
Space Space
Rest -> Bool
True
Alignment {} -> [Note sollu] -> Bool
nextRest [Note sollu]
ns
Note sollu
_ -> Bool
False
type Variations = [(S.Matra, S.Matra, S.Matra)]
vary :: (S.Matra -> Variations)
-> S.Sequence g (Note sollu) -> [S.Sequence g (Note sollu)]
vary :: forall g sollu.
(Int -> Variations)
-> Sequence g (Note sollu) -> [Sequence g (Note sollu)]
vary Int -> Variations
allowedVariations Sequence g (Note sollu)
notes
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [[((Int, Int, Int), (Int, Int, Int))]]
modificationGroups = [Sequence g (Note sollu)
notes]
| Bool
otherwise = forall a b. (a -> b) -> [a] -> [b]
map forall {t :: * -> *}.
Foldable t =>
t ((Int, Int, Int), (Int, Int, Int)) -> Sequence g (Note sollu)
apply [[((Int, Int, Int), (Int, Int, Int))]]
modificationGroups
where
modificationGroups :: [[((Int, Int, Int), (Int, Int, Int))]]
modificationGroups = forall a b x. (a -> [b]) -> [(a, x)] -> [[(b, x)]]
permuteFst Int -> Variations
allowedVariations (forall g sollu. Sequence g (Note sollu) -> [(Int, (Int, Int, Int))]
findTriads Sequence g (Note sollu)
notes)
apply :: t ((Int, Int, Int), (Int, Int, Int)) -> Sequence g (Note sollu)
apply t ((Int, Int, Int), (Int, Int, Int))
mods = forall g a. [Note g a] -> Sequence g a
S.fromList forall a b. (a -> b) -> a -> b
$ forall a mod. (a -> mod -> a) -> [(Int, mod)] -> [a] -> [a]
applyModifications
(\Note g (Note sollu)
_ Int
matras -> forall g a. a -> Note g a
S.Note (forall sollu. Pattern -> Note sollu
Pattern (Int -> Pattern
PatternM Int
matras)))
(forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {b} {a}. ((b, b, b), (a, a, a)) -> [(a, b)]
extract t ((Int, Int, Int), (Int, Int, Int))
mods) (forall g a. Sequence g a -> [Note g a]
S.toList Sequence g (Note sollu)
notes)
extract :: ((b, b, b), (a, a, a)) -> [(a, b)]
extract ((b
m1, b
m2, b
m3), (a
i1, a
i2, a
i3)) = [(a
i1, b
m1), (a
i2, b
m2), (a
i3, b
m3)]
variations :: [(S.Matra, S.Matra, S.Matra) -> Bool] -> (S.Matra -> Variations)
variations :: [(Int, Int, Int) -> Bool] -> Int -> Variations
variations [(Int, Int, Int) -> Bool]
filters = forall a. (a -> Bool) -> [a] -> [a]
filter (\(Int, Int, Int)
v -> forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall a b. (a -> b) -> a -> b
$(Int, Int, Int)
v) [(Int, Int, Int) -> Bool]
filters) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Variations
allVariations
ascending, descending, standard :: (S.Matra, S.Matra, S.Matra) -> Bool
ascending :: (Int, Int, Int) -> Bool
ascending (Int
m1, Int
m2, Int
m3) = Int
m1 forall a. Ord a => a -> a -> Bool
< Int
m2 Bool -> Bool -> Bool
&& Int
m2 forall a. Ord a => a -> a -> Bool
< Int
m3
descending :: (Int, Int, Int) -> Bool
descending (Int
m1, Int
m2, Int
m3) = Int
m1 forall a. Ord a => a -> a -> Bool
> Int
m2 Bool -> Bool -> Bool
&& Int
m2 forall a. Ord a => a -> a -> Bool
> Int
m3
standard :: (Int, Int, Int) -> Bool
standard (Int
m1, Int
m2, Int
m3) =
Int
m1 forall a. Eq a => a -> a -> Bool
== Int
m2 Bool -> Bool -> Bool
&& Int
m2 forall a. Eq a => a -> a -> Bool
== Int
m3
Bool -> Bool -> Bool
|| forall a. Ord a => [a] -> [a]
List.sort [Int
m1, Int
m2, Int
m3] forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Int
5, Int
6, Int
7], [Int
6, Int
7, Int
8], [Int
5, Int
7, Int
9]]
allVariations :: S.Matra -> Variations
allVariations :: Int -> Variations
allVariations Int
matras = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Int -> Variations
vars [Int
0 .. forall a. Ord a => a -> a -> a
max Int
1 (Int
matras forall a. Num a => a -> a -> a
- Int
minDuration)]
where
vars :: Int -> Variations
vars Int
d
| Int
d forall a. Eq a => a -> a -> Bool
== Int
0 = [(Int
matras, Int
matras, Int
matras)]
| Bool
otherwise =
[ (Int
matras forall a. Num a => a -> a -> a
- Int
d, Int
matras, Int
matras forall a. Num a => a -> a -> a
+ Int
d)
, (Int
matras forall a. Num a => a -> a -> a
+ Int
d, Int
matras, Int
matras forall a. Num a => a -> a -> a
- Int
d)
]
minDuration :: Int
minDuration = Int
3
findTriads :: S.Sequence g (Note sollu) -> [(S.Matra, (Int, Int, Int))]
findTriads :: forall g sollu. Sequence g (Note sollu) -> [(Int, (Int, Int, Int))]
findTriads Sequence g (Note sollu)
notes =
[ (Int
matras, (Int, Int, Int)
triad)
| (Int
matras, [Int]
indices) <- forall a b. Ord a => [(a, b)] -> [(a, NonNull b)]
Lists.groupFst
[ (Int
matras, Int
i)
| (Int
i, S.Note (Pattern (PatternM Int
matras))) <- forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..] (forall g a. Sequence g a -> [Note g a]
S.toList Sequence g (Note sollu)
notes)
]
, (Int, Int, Int)
triad <- forall {c}. [c] -> [(c, c, c)]
triads [Int]
indices
]
where
triads :: [c] -> [(c, c, c)]
triads (c
x1:c
x2:c
x3:[c]
xs) = (c
x1, c
x2, c
x3) forall a. a -> [a] -> [a]
: [c] -> [(c, c, c)]
triads [c]
xs
triads [c]
_ = []
newtype Exception = Exception Text
deriving (Exception -> Exception -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Exception -> Exception -> Bool
$c/= :: Exception -> Exception -> Bool
== :: Exception -> Exception -> Bool
$c== :: Exception -> Exception -> Bool
Eq)
instance Exception.Exception Exception
instance Show Exception where
show :: Exception -> String
show (Exception Text
msg) = Text -> String
Text.unpack Text
msg
throw :: CallStack.Stack => Text -> a
throw :: forall a. HasCallStack => Text -> a
throw = forall e a. (HasCallStack, Exception e) => (Text -> e) -> Text -> a
CallStack.throw Text -> Exception
Exception
applyModifications :: (a -> mod -> a) -> [(Int, mod)]
-> [a] -> [a]
applyModifications :: forall a mod. (a -> mod -> a) -> [(Int, mod)] -> [a] -> [a]
applyModifications a -> mod -> a
apply [(Int, mod)]
mods = forall {a}. Ord a => [(a, mod)] -> [(a, a)] -> [a]
go [(Int, mod)]
mods forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. [a] -> [b] -> [(a, b)]
zip [Int
0..]
where
go :: [(a, mod)] -> [(a, a)] -> [a]
go [] [(a, a)]
xs = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(a, a)]
xs
go [(a, mod)]
_ [] = []
go ((a
i1, mod
mod) : [(a, mod)]
mods) ((a
i2, a
x) : [(a, a)]
xs)
| a
i1 forall a. Ord a => a -> a -> Bool
< a
i2 = [(a, mod)] -> [(a, a)] -> [a]
go [(a, mod)]
mods ((a
i2, a
x) forall a. a -> [a] -> [a]
: [(a, a)]
xs)
| a
i1 forall a. Eq a => a -> a -> Bool
== a
i2 = a -> mod -> a
apply a
x mod
mod forall a. a -> [a] -> [a]
: [(a, mod)] -> [(a, a)] -> [a]
go [(a, mod)]
mods [(a, a)]
xs
| Bool
otherwise = a
x forall a. a -> [a] -> [a]
: [(a, mod)] -> [(a, a)] -> [a]
go ((a
i1, mod
mod) forall a. a -> [a] -> [a]
: [(a, mod)]
mods) [(a, a)]
xs
permuteFst :: (a -> [b]) -> [(a, x)] -> [[(b, x)]]
permuteFst :: forall a b x. (a -> [b]) -> [(a, x)] -> [[(b, x)]]
permuteFst a -> [b]
_ [] = []
permuteFst a -> [b]
permutations ((a
k, x
x) : [(a, x)]
xs)
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(a, x)]
xs = [[(b
p, x
x)] | b
p <- a -> [b]
permutations a
k]
| Bool
otherwise =
[(b
p, x
x) forall a. a -> [a] -> [a]
: [(b, x)]
rest | b
p <- a -> [b]
permutations a
k, [(b, x)]
rest <- forall {x}. [(a, x)] -> [[(b, x)]]
go [(a, x)]
xs]
where go :: [(a, x)] -> [[(b, x)]]
go = forall a b x. (a -> [b]) -> [(a, x)] -> [[(b, x)]]
permuteFst a -> [b]
permutations
check :: CallStack.Stack => Either Error a -> a
check :: forall a. HasCallStack => Either Text a -> a
check = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either forall a. HasCallStack => Text -> a
throw forall a. a -> a
id
checkMsg :: CallStack.Stack => Text -> Either Error a -> a
checkMsg :: forall a. HasCallStack => Text -> Either Text a -> a
checkMsg Text
msg = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a. HasCallStack => Text -> a
throw forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Text
msg forall a. Semigroup a => a -> a -> a
<> Text
": ") <>)) forall a. a -> a
id