-
-
Save dustinlacewell/0bd14c3457ee70b6a840149268d0c97f to your computer and use it in GitHub Desktop.
This file contains 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
"the cow ate the grass" | |
"the cow ate the grass" | |
app/Main.hs:34:8-15: error: | |
• Occurs check: cannot construct the | |
infinite type: a ~ a -> a | |
Expected type: [a] | |
Actual type: [a -> a] | |
• In the expression: map f xs | |
In the expression: | |
let | |
a' = f a b | |
xs = b : cs | |
in map f xs | |
In an equation for ‘map2’: | |
map2 f (a : b : cs) | |
= let | |
a' = f a b | |
xs = b : cs | |
in map f xs | |
• Relevant bindings include | |
a' :: a (bound at app/Main.hs:32:9) | |
xs :: [a] (bound at app/Main.hs:33:9) | |
cs :: [a] (bound at app/Main.hs:31:13) | |
b :: a (bound at app/Main.hs:31:11) | |
a :: a (bound at app/Main.hs:31:9) | |
f :: a -> a -> a (bound at app/Main.hs:31:6) | |
(Some bindings suppressed; use | |
-fmax-relevant-binds=N or -fno-max-relevant-binds) | |
| | |
34 | in map f xs | |
| ^^^^^^^^ |
This file contains 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
map2 :: (a -> a -> a) -> [a] -> [a] | |
map2 f [] = [] | |
map2 f [a] = [a] | |
map2 f (a:[b]) = [f a b, b] | |
map2 f (a:b:cs) = | |
let a' = f a b | |
xs = b:cs | |
in map f xs | |
main :: IO () | |
main = do | |
let s = "the cow ate the grass" | |
print s | |
print $ map2 (\c1 c2 -> if c1 `elem` "aeiou" then '!' else c1) s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment