Skip to content

Instantly share code, notes, and snippets.

@Wizek
Last active January 29, 2017 02:40
Show Gist options
  • Save Wizek/0b51ad8413bdcfe24c600e1907324ade to your computer and use it in GitHub Desktop.
Save Wizek/0b51ad8413bdcfe24c600e1907324ade to your computer and use it in GitHub Desktop.
import qualified Data.HashMap as HM
hmAt :: (Functor f, Ord t, Hashable t) => t -> (Maybe a -> f b) -> HM.Map t a -> f t1
hmAt k = lens g s
where
s v = HM.insert k v
g = HM.lookup k
src/Test/Hspec.hs:75:
2) ! eff
uncaught exception: TypeError (/path/to/spec/Spec.hs:1353:10: error:
• Couldn't match type ‘b’ with ‘HM.Map t a0’
‘b’ is a rigid type variable bound by
the type signature for:
hmAt :: forall (f :: * -> *) t a b t1.
(Functor f, Ord t, Hashable t) =>
t -> (Maybe a -> f b) -> HM.Map t a -> f t1
at /path/to/spec/Spec.hs:1352:9
Expected type: (Maybe a -> f b) -> HM.Map t a -> f t1
Actual type: (Maybe a -> f (HM.Map t a0))
-> HM.Map t a -> f (HM.Map t a0)
• In the expression: lens g s
In an equation for ‘hmAt’:
hmAt k
= lens g s
where
s (Just v) = HM.insert k v
g = HM.lookup k
• Relevant bindings include
s :: forall a. Maybe a -> HM.Map t a -> HM.Map t a
(bound at /path/to/spec/Spec.hs:1355:3)
g :: forall a. HM.Map t a -> Maybe a
(bound at /path/to/spec/Spec.hs:1356:3)
k :: t
(bound at /path/to/spec/Spec.hs:1353:6)
hmAt :: t -> (Maybe a -> f b) -> HM.Map t a -> f t1
(bound at /path/to/spec/Spec.hs:1353:1)
(deferred type error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment