{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Study.Decks.Eberban.English.Roots
( deck
) where
import Core
import Language.Eberban.Core
import Language.Eberban.Dictionaries (officialDictionary)
import Study.Framework.Eberban.ExerciseGenerators (generateLexiconProvidingExercise)
import Study.Framework.DocumentBuilders (buildDocumentFromMarkdownCode)
import Data.FileEmbed (embedStringFile)
import Util (generatorFromList)
import qualified Data.Map as M
import qualified Text.Pandoc as P
import qualified Language.Lojban.Dictionaries as LojbanDictionaries
longDescription :: P.Pandoc
Right Pandoc
longDescription = Text -> Either PandocError Pandoc
buildDocumentFromMarkdownCode $(embedStringFile "resources/decks/eberban/english/roots/description.md")
deck :: Deck
deck :: Deck
deck = Text
-> Text
-> Text
-> Maybe Pandoc
-> Maybe Pandoc
-> Dictionary
-> [Card]
-> Deck
Deck Text
id Text
title Text
shortDescription (Pandoc -> Maybe Pandoc
forall a. a -> Maybe a
Just Pandoc
longDescription) Maybe Pandoc
forall {a}. Maybe a
credits Dictionary
LojbanDictionaries.englishDictionary [Card]
cards where
id :: Text
id = Text
"eberban-eng_roots"
title :: Text
title = Text
"Eberban roots"
shortDescription :: Text
shortDescription = Text
"Learn the officially registered Eberban roots."
credits :: Maybe a
credits = Maybe a
forall {a}. Maybe a
Nothing
cards :: [Card]
cards :: [Card]
cards = (Entry -> Card) -> [Entry] -> [Card]
forall a b. (a -> b) -> [a] -> [b]
map Entry -> Card
buildCard [Entry]
rootList where
entryList :: [Entry]
entryList :: [Entry]
entryList = ((Text, Entry) -> Entry) -> [(Text, Entry)] -> [Entry]
forall a b. (a -> b) -> [a] -> [b]
map (Text, Entry) -> Entry
forall a b. (a, b) -> b
snd ([(Text, Entry)] -> [Entry]) -> [(Text, Entry)] -> [Entry]
forall a b. (a -> b) -> a -> b
$ Map Text Entry -> [(Text, Entry)]
forall k a. Map k a -> [(k, a)]
M.toList (Dictionary -> Map Text Entry
dictEntries Dictionary
officialDictionary)
rootList :: [Entry]
rootList :: [Entry]
rootList = (Entry -> Bool) -> [Entry] -> [Entry]
forall a. (a -> Bool) -> [a] -> [a]
filter ((Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"R") (Text -> Bool) -> (Entry -> Text) -> Entry -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Entry -> Text
entryFamily) [Entry]
entryList
buildCard :: Entry -> Card
buildCard :: Entry -> Card
buildCard Entry
root = Text -> Text -> ExerciseGenerator -> Card
Card (Entry -> Text
entryText Entry
root) (Entry -> Text
entryEnglishLong Entry
root) (Entry -> ExerciseGenerator
buildRootExerciseGenerator Entry
root)
buildRootExerciseGenerator :: Entry -> ExerciseGenerator
buildRootExerciseGenerator :: Entry -> ExerciseGenerator
buildRootExerciseGenerator Entry
root = Text -> EntryGenerator -> ExerciseGenerator
generateLexiconProvidingExercise Text
"root" (EntryGenerator -> ExerciseGenerator)
-> EntryGenerator -> ExerciseGenerator
forall a b. (a -> b) -> a -> b
$ [Entry] -> EntryGenerator
forall a. [a] -> StdGen -> (a, StdGen)
generatorFromList [Entry
root]