git.iko.soy/rowtype-yoga/purescript-yoga-om-layer
on main help sign in
87 lines 2.1 kB history raw
1# Try the Error Messages!
3## Super Easy Method
51. Open `test/Playground.purs` in your editor
62. **Uncomment ONE example** (lines have `-- example1`, `-- example2`, etc.)
73. Run:
8 ```bash
9 cd packages/yoga-om-layer
10 npx spago build -p yoga-om-layer
11 ```
124. See the beautiful error message! ๐ŸŽ‰
14## Examples to Try
16### Example 1: Missing Everything โŒ
17Uncomment:
18```purescript
19example1 :: Om (Record ()) () (Record (logger :: Logger))
20example1 = runLayer {} loggerLayer
21```
23**Error shows:**
24- First missing field: `"config"`
25- Required: `(config :: { ... })`
26- Provided: `()`
28---
30### Example 2: Partial Context โŒ
31Uncomment:
32```purescript
33example2 :: Om (Record (logger :: Logger)) () (Record (cache :: Cache))
34example2 = runLayer { logger: { log: \_ -> pure unit } } cacheLayer
35```
37**Error shows:**
38- First missing field: `"database"`
39- Required: `(logger :: {...}, database :: {...})`
40- Provided: `(logger :: {...})`
42You can see `logger` โœ… is there but `database` โŒ is missing!
44---
46### Example 3: Multiple Missing โŒ
47Uncomment:
48```purescript
49combined :: OmLayer (config :: Config) (logger :: Logger, database :: Database) ()
50combined = combineRequirements loggerLayer databaseLayer
52example3 :: Om (Record ()) () (Record (logger :: Logger, database :: Database))
53example3 = runLayer {} combined
54```
56**Error shows the full diff** with multiple missing dependencies!
58---
60### Example 4: Success! โœ…
61Uncomment:
62```purescript
63example4 :: Om (Record (config :: Config)) () (Record (logger :: Logger))
64example4 = runLayer { config: { port: 5432, host: "localhost" } } loggerLayer
65```
67**This one compiles!** No errors because all dependencies are satisfied.
69---
71## Tips
73- Try uncommenting MULTIPLE examples at once to see different errors
74- Modify the type signatures to create your own error scenarios
75- Add more layers and combine them to see how deduplication works
76- Check out the test suite in `test/Test/Main.purs` for working examples
78## Quick Test
80```bash
81# Run the full test suite
82cd packages/yoga-om-layer
83npx spago test
85# Run negative error tests
86./test-errors.sh
87```