pcmt/config.dhall
leo f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
add bulk changes
* add handlers for signin,singup,logout...
* introduce ent ORM and add user schema
* add live mode, devel mode to selectively turn on features via
  config/flags
* add templates, handle embedding moar smarter:
  * live mode uses live folder structure, else embedded templates are
    used
* start using tailwindcss to style stuff
* add development goodies for hot-reloading (browser-sync - bs.js)
* pimp-up config.dhall with actual custom config Type (enables remote
  schema and local values only as needed)
* add justfile (alternative to makefile for process automation)
2023-04-13 00:07:08 +02:00

92 lines
2.3 KiB
Haskell

-- convenience funcs for validation.
let Prelude =
https://prelude.dhall-lang.org/v20.2.0/package.dhall
sha256:a6036bc38d883450598d1de7c98ead113196fe2db02e9733855668b18096f07b
let NuConfig =
-- | define a configuration schema.
{ Type =
{ Port : Natural
, AppName : Text
, LiveMode : Bool
, DevelMode : Bool
, LoginCookieName : Optional Text
}
, default =
{ Port = 3000
, AppName = "pcmt"
, LiveMode = False
, DevelMode = False
, LoginCookieName = None Text
}
}
let NuConfig/validate
: NuConfig.Type -> Type
=
-- | define validation.
\(c : NuConfig.Type) ->
let expected = { validPort = True }
let actual =
{ validPort =
-- | make sure port number belongs to the <1;65565> range.
Prelude.Natural.lessThanEqual 1 c.Port
&& Prelude.Natural.lessThanEqual c.Port 65565
}
in expected === actual
let nuconf = NuConfig::{ LiveMode = True, DevelMode = True }
let _ =
-- | validate the configuration.
assert : NuConfig/validate nuconf
let Config =
-- | define configuration schema.
{ Port : Natural
, AppName : Text
, LiveMode : Bool
, DevelMode : Bool
, LoginCookieName : Optional Text
}
let defconf
-- | a full default configuration.
-- | TODO: have this reside on the Internet and import it similar to how
-- | the Dhall Prelude is imported.
: Config
= { Port = 3000
, AppName = "pcmt"
, LiveMode = False
, DevelMode = False
, LoginCookieName = None Text
}
let conf
: Config
= defconf // { LiveMode = True, DevelMode = False }
let Config/validate
: Config -> Type
=
-- | define validation.
\(config : Config) ->
let expected = { validPort = True }
let actual =
{ validPort =
-- | make sure port number belongs to the <1;65565> range.
Prelude.Natural.lessThanEqual 1 config.Port
&& Prelude.Natural.lessThanEqual config.Port 65565
}
in expected === actual
let _ =
-- | validate the configuration.
assert : Config/validate conf
in nuconf