Skip to content

Instantly share code, notes, and snippets.

@FruitieX
Created March 5, 2018 08:11
Show Gist options
  • Select an option

  • Save FruitieX/5b170dc90b68474836a52c7bcb9bfd7f to your computer and use it in GitHub Desktop.

Select an option

Save FruitieX/5b170dc90b68474836a52c7bcb9bfd7f to your computer and use it in GitHub Desktop.
newtype LuminaireState = LuminaireState
{ gateway :: GatewayId
, lights :: Map LightId LightState
}
derive instance newtypeLuminaireState :: Newtype LuminaireState _
...
setLight :: forall e. LuminaireId -> LightId -> LightColor -> Maybe Milliseconds -> AppState -> Eff (ref :: REF | e) Boolean
setLight luminaireId lightId color transitionTime appState = do
curLuminaireState <- lookup luminaireId <$> readRef appState
lights <- _.lights <$> (unwrap <$> curLuminaireState) -- boom
pure true
-- error:
Error found:
in module State
at src/State.purs line 30, column 3 - line 30, column 56
Could not match type
Maybe
with type
Eff
( ref :: REF
| t0
)
while trying to match type Maybe t2
with type Eff
( ref :: REF
| t0
)
t1
while checking that expression (bind ((map (...)) ((...) curLuminaireState))) (\$1 ->
case $1 of
lights -> ...
)
has type Eff
( ref :: REF
| t0
)
t1
in value declaration setLight
where t1 is an unknown type
t0 is an unknown type
t2 is an unknown type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment