blob: 8178e9a48c8905672d67f0cf01c39dbe5d745264 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Com.MusicMeetsComics.Database
(
ComicDB
, getComics
, load
) where
import Com.MusicMeetsComics.App
import Data.Map ( Map )
import qualified Data.Map as Map
import Dhall
import Protolude
import Servant ( Handler )
type ComicDB = (Map ComicId Comic)
instance Interpret Comic
load :: IO ComicDB
load = listToComicDB <$> input auto "./comic-database.dhall"
listToComicDB :: [Comic] -> ComicDB
listToComicDB ls = Map.fromList $ (,) <$> comicId <*> identity <$> ls
getComics :: ComicDB -> Handler [Comic]
getComics db = return $ Map.elems db
|