@@ -17,8 +17,8 @@ type Config =
1717 , count :: Int
1818 }
1919
20- readConfig :: Object String -> Either String Config
21- readConfig env =
20+ parseConfig :: Object String -> Either String Config
21+ parseConfig env =
2222 (\greeting count -> { greeting, count })
2323 <$> value "GREETING"
2424 <*> ( value "COUNT"
@@ -44,12 +44,12 @@ type Config =
4444 }
4545```
4646
47- The ` fromEnv ` function can now convert the environment ` Object String ` to a typed record with no need for explicit
48- lookups, parsing, or error handling:
47+ The ` fromEnv ` function now has enough information to convert the environment ` Object String ` to a typed record with
48+ no need for explicit lookups, parsing, or error handling:
4949
5050``` purescript
51- readConfig :: Object String -> Either String Config
52- readConfig env =
51+ parseConfig :: Object String -> Either String Config
52+ parseConfig env =
5353 bimap
5454 printEnvError
5555 (\r -> { greeting: r."GREETING", count: r."COUNT" })
@@ -60,21 +60,19 @@ readConfig env =
6060> An additional benefit not demonstrated here is that the ` TypedEnv.fromEnv ` function accumulates a list of
6161> errors, whereas the former example can only present one error at a time.
6262
63- For more, see the [ examples ] ( #examples ) section below.
63+ ### Examples
6464
65- ### Installation
65+ To run one of the [ examples ] ( example ) , clone the repository and run the following command, replacing ` <example-name> ` with the name of the example.
6666
67- via [ spago] ( https://github.com/spacchetti/spago ) :
6867``` bash
69- spago install typedenv
68+ spago -x example.dhall run -m Example. < example-name >
7069```
7170
72- ### Examples
73-
74- To run one of the [ examples] ( example ) , clone the repository and run the following command, replacing ` <example-name> ` with the name of the example.
71+ ### Installation
7572
73+ via [ spago] ( https://github.com/spacchetti/spago ) :
7674``` bash
77- spago run -p example/ < example-name > .purs -m Example. < example-name >
75+ spago install typedenv
7876```
7977
8078### Similar ideas
0 commit comments