I have a type Either a [b] and a function f :: (b -> c)
How can I use f on a value of type Either a [b] to get Either a [c] ?
I have a type Either a [b] and a function f :: (b -> c)
How can I use f on a value of type Either a [b] to get Either a [c] ?
Copyright © 2021 Jogjafile Inc.
Use
fmapfunction on it.Either is an instance of the Functor typeclass with the first type fixed:
and the fmap type for
Either atherefore would be:Appliction of fmap to Either leads to: Left data constructor of type a remains unchanged, and the Right data constructor of type b gets the function f applied to get to the type c.