|
| 1 | +{-| |
| 2 | +Module : Haskellings.Constants |
| 3 | +Description : Constant expressions for Haskellings |
| 4 | +License : BSD3 |
| 5 | +Maintainer : james@mondaymorninghaskell.me |
| 6 | +
|
| 7 | +This module has constant values that are used across Haskellings. |
| 8 | +It includes things like the string for the GHC version currently in use, |
| 9 | +hard-coded directory and file names, and required libraries. |
| 10 | +-} |
| 11 | + |
| 12 | +module Haskellings.Constants |
| 13 | +( -- * Version strings |
| 14 | + -- | Includes the GHC version currently in use, and the Haskellings version. |
| 15 | + ghcVersion |
| 16 | + , ghcVersionNumber |
| 17 | + , haskellingsVersion |
| 18 | + -- * Files and directories |
| 19 | + -- | These help us locate the exercises and configurations. |
| 20 | + , projectRootDirName |
| 21 | + , mainProjectExercisesDir |
| 22 | + , configFileName |
| 23 | + -- * Required Libraries |
| 24 | + -- | Haskellings requires these are installed with the Stack package |
| 25 | + -- in order to function. |
| 26 | + , haskellingsRequiredLibs |
| 27 | + -- * CI Constants |
| 28 | + -- | These help us to run tests in the Circle CI environment. |
| 29 | + , envIsCi |
| 30 | + , ciProjectRootDirName |
| 31 | +) where |
| 32 | + |
| 33 | +import Data.Maybe |
| 34 | +import System.Environment |
| 35 | + |
| 36 | +-- | The GHC version currently used by Haskellings. We use this |
| 37 | +-- to locate the appropriate GHC executable. |
| 38 | +ghcVersion :: String |
| 39 | +ghcVersion = "ghc-8.10.4" |
| 40 | + |
| 41 | +-- | The version number, isolated from any prefix. Also helps in |
| 42 | +-- finding certain directories. |
| 43 | +ghcVersionNumber :: String |
| 44 | +ghcVersionNumber = "8.10.4" |
| 45 | + |
| 46 | +-- | The current Haskellings program version. |
| 47 | +haskellingsVersion :: String |
| 48 | +haskellingsVersion = "0.8.0.0" |
| 49 | + |
| 50 | +-- | The project root directory name. We need to find the project root |
| 51 | +-- in order to locate the exercises. |
| 52 | +projectRootDirName :: String |
| 53 | +projectRootDirName = "haskellings" |
| 54 | + |
| 55 | +-- | The name of the exercises directory. |
| 56 | +mainProjectExercisesDir :: String |
| 57 | +mainProjectExercisesDir = "exercises" |
| 58 | + |
| 59 | +-- | The name of the config file, which can store a custom GHC location. |
| 60 | +configFileName :: String |
| 61 | +configFileName = "config.yaml" |
| 62 | + |
| 63 | +-- | A listing of packages required by exercises, so we can use them |
| 64 | +-- to filter Stack snapshots |
| 65 | +haskellingsRequiredLibs :: [String] |
| 66 | +haskellingsRequiredLibs = |
| 67 | + [ "tasty" |
| 68 | + , "tasty-hunit" |
| 69 | + ] |
| 70 | + |
| 71 | +-- | Tells us if we are running in a Circle CI environment. This affects |
| 72 | +-- how we construct the path and find the exercises. |
| 73 | +envIsCi :: IO Bool |
| 74 | +envIsCi = isJust <$> lookupEnv ciEnvName |
| 75 | + |
| 76 | +-- | The project root name when running on Circle CI. |
| 77 | +ciProjectRootDirName :: String |
| 78 | +ciProjectRootDirName = "project" |
| 79 | + |
| 80 | +---------- PRIVATE FUNCTIONS ---------- |
| 81 | + |
| 82 | +-- We set this environment variable on Circle CI. |
| 83 | +ciEnvName :: String |
| 84 | +ciEnvName = "HASKELLINGS_CI_ENV" |
0 commit comments