4 ms·
One thing that could help you understand is that Haskell has many types which act kind of like containers of primitive values. One example is `Maybe a` which h
by elbear 7y ago
One thing that could help you understand is that Haskell has many types which act kind of like containers of primitive values.
One example is `Maybe a` which has a value `Just a`. `a` can have any type, including `String`, `Int`, `Float`, etc. But a function that accepts a `String` can't take `Just String` as an argument.
This is the problem that `Functor` solves. It applies your function to the value inside the container.
`Applicative` applies a function that takes two arguments to the values inside two containers. For example, you have the function: `<> :: String -> String -> String` and you apply it to two `Just String` values, like this:
ghci> liftA2 (<>) (Just "hello") (Just " world")
Just "hello world"