, traverse .
traverse f = Data f -- f :: x implies Data f :: x -> Data x, so this implies
traverse :: x -> x -> Data x
Data Traversable, Tr.traverse
Tr.traverse :: Applicative f => (a -> f b) -> Data a -> f (Data b)
:
traverse ~ Tr.traverse if and only if
x ~ (a -> f b)
x ~ Data a
Data x ~ f (Data b)
:
Couldn't match expected type `Data a' with actual type `a -> f b'
In the first argument of `Data', namely `f'
In the expression: Data f
In an equation for `traverse': traverse f = Data f
, :
traverse f (Data a a') = Data <$> f a <*> f a'
. Tr.traverse (putStrLn show) exampleData, Tr.traverse (putStrLn . show) exampleData.
putStrLn String -> IO (), putStrLn show show , show :: Show a -> a -> String.
:
Couldn't match expected type `Test -> IO b0'
with actual type `IO ()'
In the return type of a call of `putStrLn'
Probable cause: `putStrLn' is applied to too many arguments
In the first argument of `Tr.traverse', namely `(putStrLn show)'
In a stmt of a 'do' block: Tr.traverse (putStrLn show) exampleData
Couldn't match type `a0 -> String' with `[Char]'
Expected type: String
Actual type: a0 -> String
In the first argument of `putStrLn', namely `show'
In the first argument of `Tr.traverse', namely `(putStrLn show)'
In a stmt of a 'do' block: Tr.traverse (putStrLn show) exampleData
.:
putStrLn . show == \a -> putStrLn (show a)
You can also use print, which is defined as putStrLn . show.
source
share