about summary refs log blame commit diff
path: root/src/Xanthous/Entities/Raws.hs
blob: 4a4cba8c9a195d2dcbfa40fb66c0b3839403dea9 (plain) (tree)



























                                                            
{-# LANGUAGE TemplateHaskell #-}

module Xanthous.Entities.Raws
  ( raws
  , raw
  ) where

import           Data.FileEmbed
import qualified Data.Yaml as Yaml
import           Xanthous.Prelude
import           System.FilePath.Posix

import           Xanthous.Entities.RawTypes

rawRaws :: [(FilePath, ByteString)]
rawRaws = $(embedDir "src/Xanthous/Entities/Raws")

raws :: HashMap Text EntityRaw
raws
  = mapFromList
  . map (bimap
         (pack . takeBaseName)
         (either (error . Yaml.prettyPrintParseException) id
          . Yaml.decodeEither'))
  $ rawRaws

raw :: Text -> Maybe EntityRaw
raw n = raws ^. at n