module Axel.Utils.Resources where

import Control.Monad ((>=>))

import Paths_axel (getDataFileName)

import System.FilePath ((</>))

import qualified System.IO.Strict as S (readFile)

newtype Resource =
  Resource String

getResourcePath :: Resource -> IO FilePath
getResourcePath (Resource resource) = getDataFileName $ "resources" </> resource

readResource :: Resource -> IO String
readResource = getResourcePath >=> S.readFile

astDefinition :: Resource
astDefinition = Resource "autogenerated/macros/AST.hs"

macroDefinitionAndEnvironmentHeader :: Resource
macroDefinitionAndEnvironmentHeader =
  Resource "macros/MacroDefinitionAndEnvironmentHeader.hs"

macroScaffold :: Resource
macroScaffold = Resource "macros/Scaffold.hs"