Skip to content

Instantly share code, notes, and snippets.

@specdrake
Created June 17, 2020 13:20
Show Gist options
  • Save specdrake/3786683c98a0b01855de2a54961a947b to your computer and use it in GitHub Desktop.
Save specdrake/3786683c98a0b01855de2a54961a947b to your computer and use it in GitHub Desktop.
f1 = (<$> ((:[]) <$>))
f1 :: (Functor f) => (f [a] -> b) -> f a -> b
:: (Functor f) => (f [a] -> b) -> (f a -> b)
(=<<) :: (Monad m) => (a -> m b) -> m a -> m b
:: (Monad m) => (a -> m b) -> (m a -> m b)
-- Applying f1 to (=<<)
f = f1 (=<<)
f :: (a -> b) -> [a] -> [b]
:: (a -> b) -> ([a] -> [b])
-- Matching type of `(=<<)` with (f [a] -> b)
f [a] -> b
(e -> [a]) -> b -- as f ~ (e ->)
(a -> m b) -> (m a -> m b)
(a -> [b]) -> ([a] -> [b])
(e -> [a]) -> ([e] -> [a])
-- so b ~ ([e] -> [a])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment