I’m working through Chapter 5 of the PureScript book and want to make lzs
(longest zero suffix) more general. I came up with the following:
lzs :: forall a. Semiring a => Array a -> Array a
lzs [] = []
lzs xs = case sum xs of
zero -> xs
_ -> lzs (fromMaybe [] $ tail xs)
The zero
is being interpreted as a new variable with the name zero
instead of the zero
from Prelude
. Is there a way to tell PureScript to use the zero
from the global scope instead of creating a new variable?