I just discovered Data.Sequence
and it seems that there is no head
or last
function.
I know you can pattern match on viewL
, or use index 0
etc ... But is there a reason such
basic functiosn are not implemented (or I am missing them ) ?
Using Prelude.head
is usually considered bad practice: partial functions are always something of a danger; code like
if null list then
...
else
let foo = head list in ...
is often written by beginners but would of course better be expressed
case list of
[] -> ...
(foo:_) ->
So in many non-base modules, partial functions are echewed, like in this case. The preferred way is, again, pattern matching – on viewL
, as you say.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With