git.iko.soy/rowtype-yoga/purescript-yoga-om-layer
on v1.0.3 help sign in
21 lines 764 B history raw
1module Test.Negative.MissingOneField where
3import Prelude
4import Effect (Effect)
5import Yoga.Om (Om)
6import Yoga.Om as Om
7import Yoga.Om.Layer (OmLayer, makeLayer, runLayer)
9type Config = { port :: Int }
10type Logger = { log :: String -> Effect Unit }
11type Database = { query :: String -> Effect (Array String) }
13-- This layer needs BOTH config AND logger
14needsBoth :: OmLayer (config :: Config, logger :: Logger) (database :: Database) ()
15needsBoth = makeLayer do
16 { config, logger } <- Om.ask
17 pure { database: { query: \q -> pure [] } }
19-- This should NOT compile - we provide config but not logger
20testMissingOneField :: Om (Record (config :: Config)) () (Record (database :: Database))
21testMissingOneField = runLayer { config: { port: 5432 } } needsBoth