I’m not getting this type signature and I likely just don’t understand the notation.
lastbut1 :: Foldable f => f a -> a
lastbut1 = fst . foldl (\(a,b) x -> (b,x)) (err1,err2)
where
err1 = error "lastbut1: Empty list"
err2 = error "lastbut1: Singleton"
Since lastbut1
takes one argument (e.g., [1,2,3,4]
) why is there both f
and a
on the right side of =>
?
As I look at it I’m thinking that lastbut1
takes something foldable and returns a single value of the same type. So why wouldn’t the signature be:
lastbut1 :: Foldable a => a -> a
The notation I likely don’t understand is the space between f
and a
in f a -> a
.