-- import Data.Set qualified as Set
import Data.Text qualified as Text
+import System.Random qualified as Random
+import System.Random.Shuffle as Random
-- import Data.Text.Short qualified as ShortText
import System.FilePath.Posix ((</>))
}
pagesHTML :: Dicts -> Text -> Pages -> IO Builder
-pagesHTML Dicts{..} title Pages{..} = do
+pagesHTML Dicts{..} title pages = do
-- FIXME: this absolute path is not portable out of my system
dataPath <- Self.getDataDir <&> File.normalise
+ randomGen <- Random.getStdGen
+ pagesListShuffled :: [Page] <-
+ (mconcat <$>) $
+ forM (pages & pagesList) \page -> do
+ forM (page & pageMatches & chunksOf (page & pageMatchesNum)) \matches -> do
+ pageMatches <- Random.shuffleM matches
+ return page{pageMatches} -- Random.shuffleM
+ -- Random.shuffleM
+ -- forM_ (pageMatch & ol0) \(matchIdx :: Int, match) -> do
+ -- forM_ (match & matchMatters & ol1) \(matterIdx :: Natural, matter) -> do
+ -- Random.shuffleM
+ -- let n = page & pageMatchesNum & fromIntegral
+ -- in let (q, r) = page & pageMatches & List.length & (div n)
+ -- in List.unfoldr _ (List.replicate q n <> [r])
return $ Blaze.renderMarkupBuilder do
HTML.docTypeHtml do
HTML.head do
! HA.type_ "text/css"
! HA.href (dataPath </> cssFile & toValue)
-- styleCSS $ cssPrintPage pageOrientation pageSize
- HTML.styleCSS $ pagesDifficulties & difficultyCSS
+ HTML.styleCSS $ pages & pagesDifficulties & difficultyCSS
HTML.body do
- forM_ pagesList \page -> do
+ forM_ (pages & pagesList) \page -> do
"\n"
forM_ (page & pageMatches & chunksOf (page & pageMatchesNum)) \pageMatch -> do
HTML.section