Why there is no head function for Seq in Haskell

I just discovered Data.Sequenceand it seems that there is no function heador last. I know that you can match pattern matching to viewLor use index 0etc. But is there such a reason the basic functions are not implemented (or am I missing them)?

+4
source share
1 answer

Usage is Prelude.headgenerally considered bad practice: partial functions are always dangerous; code as

if null list then
  ...
 else
  let foo = head list in ...

often recorded by beginners, but of course it’s better to be pronounced

case list of
  [] -> ...
  (foo:_) ->

, - , . , , – viewL, .

+9

All Articles