Last active
March 5, 2018 09:03
-
-
Save FruitieX/a3aab30e39590d05c60f300f824b70bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- types | |
| newtype LightId = LightId String | |
| instance showLightId :: Show LightId where | |
| show (LightId id) = show id | |
| derive instance eqLightId :: Eq LightId | |
| derive instance ordLightId :: Ord LightId | |
| derive instance newtypeLightId :: Newtype LightId _ | |
| newtype Light = Light | |
| { color :: LightColor | |
| , prevColor :: LightColor | |
| , transitionStart :: Instant | |
| , transitionTime :: Milliseconds | |
| } | |
| newtype Luminaire = Luminaire | |
| { gateway :: GatewayId | |
| , lights :: Map LightId Light | |
| } | |
| derive instance newtypeLuminaire :: Newtype Luminaire _ | |
| type Luminaires = Ref (Map LuminaireId Luminaire) | |
| -- this one works (or at least compiles) | |
| getLuminaire | |
| :: forall e | |
| . LuminaireId | |
| -> Luminaires | |
| -> Eff (ref :: REF) (Maybe Luminaire) | |
| getLuminaire id luminaires = do | |
| lookup id <$> readRef luminaires | |
| -- this one doesn't | |
| getLuminaireLight | |
| :: forall e | |
| . LuminaireId | |
| -> LightId | |
| -> Luminaires | |
| -> Eff (ref :: REF) (Maybe Light) | |
| getLuminaireLight id lid luminaires = do | |
| luminaire <- getLuminaire id luminaires | |
| let lights = _.lights <<< unwrap <$> luminaire | |
| let light = lookup lid <$> lights -- boom | |
| pure light | |
| ------------------------------ | |
| Error found: | |
| in module Luminaire | |
| at src/Luminaire.purs line 57, column 3 - line 57, column 42 | |
| Could not match type | |
| Maybe t0 | |
| with type | |
| Light | |
| while trying to match type Maybe (Maybe t0) | |
| with type Maybe Light | |
| while checking that expression (bind ((getLuminaire id) luminaires)) (\$1 -> | |
| case $1 of | |
| luminaire -> ... | |
| ) | |
| has type Eff | |
| ( ref :: REF | |
| ) | |
| (Maybe Light) | |
| in value declaration getLuminaireLight | |
| where t0 is an unknown type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment