Why is such a definition of a null function in Haskell Prelude so strange?

The function definition nullin Prelude is as follows:

null             :: [a] -> Bool
null []          =  True
null (_:_)       =  False

What confused me is the third line of the definition, why she writes:

null(_:_)        = False

Instead:

null any = False

Does it have anything to do with compiler optimization?

+6
source share
1 answer

Does it have anything to do with compiler optimization?

, , null (_:_) , null any ( , ), Haskell , "". , , , , . , , ghc , , .

, wilcard _ ( any), ( ). , , - . , :

data [a] = [] | (a:[a]) | (Int///[a])

, , , . , :), null: , , , (_///_) . , null any.

, : , , , .

+5

All Articles