Skip to content

Instantly share code, notes, and snippets.

@swuecho
Created June 29, 2017 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swuecho/a0e7bc8be786c8b87292a2cf502dcbfd to your computer and use it in GitHub Desktop.
Save swuecho/a0e7bc8be786c8b87292a2cf502dcbfd to your computer and use it in GitHub Desktop.
Prelude> (fmap . const) 1 [1..5]
[1,1,1,1,1]
Prelude> fmap . const 1 [1..5]
<interactive>:29:1: error:
• Non type-variable argument in the constraint: Num (a1 -> a -> b)
(Use FlexibleContexts to permit this)
• When checking the inferred type
it :: forall b a (f :: * -> *) a1.
(Num (a1 -> a -> b), Functor f) =>
a1 -> f a -> f b
@swuecho
Copy link
Author

swuecho commented Jun 29, 2017

Prelude> (fmap . const ) 2 Just 3
2
Prelude> 2 <$ Just 3
Just 2
Prelude> :t (<$)
(<$) :: Functor f => a -> f b -> f a
Prelude> :t fmap . const
fmap . const :: Functor f => b -> f a -> f b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment