git.iko.soy/rowtype-yoga/purescript-yoga-config
on main help sign in
Bump to 0.2.0
commitb6b38d2d7d5241e757061f7c43746e3a92479ec1 authorMark <mark.eibes@gmail.com> dateSun 1 Mar 2026, 14:55 (7 months ago) parent7d474ef
3 files changed+21−2
spago.yaml+1−1 src/Yoga/Config.purs+1−1 src/Yoga/Config/Types.purs+19
spago.yaml+1−1
@@ -9,7 +9,7 @@ workspace:
99package:
1010 name: yoga-config
1111 publish:
12− version: 0.1.0
12+ version: 0.2.0
1313 license: MIT
1414 location:
1515 githubOwner: rowtype-yoga
src/Yoga/Config.purs+1−1
@@ -14,7 +14,7 @@ import Data.Foldable (foldl)
1414import Data.Newtype (un)
1515import Effect.Aff (Aff)
1616import Yoga.Config.Source (ConfigSource(..), fromEnvPrefix, fromFile, fromFileOptional, fromJSONFile, fromJSONString, fromProfileDir, fromRecord, fromTOMLFile, fromTOMLString, fromYAMLFile, fromYAMLString, override, withEnvResolution)
17−import Yoga.Config.Types (Duration(..), Bytes(..), Port(..), Secret, mkSecret, revealSecret, NonBlank, mkNonBlank, unNonBlank, bytesToNumber)
17+import Yoga.Config.Types (Duration(..), Bytes(..), Port(..), Hostname(..), Secret, mkSecret, revealSecret, NonBlank, mkNonBlank, unNonBlank, bytesToNumber)
1818import Yoga.Config.TOML (parseTOML)
1919import Yoga.Config.YAML (parseYAML)
2020import Yoga.JSON (class ReadForeign, E, readImpl)
src/Yoga/Config/Types.purs+19
@@ -2,6 +2,7 @@ module Yoga.Config.Types
22 ( Duration(..)
33 , Bytes(..)
44 , Port(..)
5+ , Hostname(..)
56 , Secret
67 , mkSecret
78 , revealSecret
@@ -139,6 +140,24 @@ instance ReadForeign Port where
139140instance WriteForeign Port where
140141 writeImpl (Port n) = writeImpl n
141142
143+-- | A hostname string, validated to be non-empty
144+newtype Hostname = Hostname String
145+
146+derive instance Newtype Hostname _
147+derive newtype instance Eq Hostname
148+derive newtype instance Ord Hostname
149+derive newtype instance Show Hostname
150+
151+instance ReadForeign Hostname where
152+ readImpl f = do
153+ str <- readString f
154+ let trimmed = trim str
155+ if length trimmed > 0 then pure (Hostname trimmed)
156+ else except $ note (singleton (ForeignError "Expected hostname, got empty string")) Nothing
157+
158+instance WriteForeign Hostname where
159+ writeImpl (Hostname s) = writeImpl s
160+
142161-- | A secret value that masks itself in Show to prevent accidental logging.
143162-- | Use `revealSecret` to access the underlying value.
144163newtype Secret a = Secret a