haskell 如何以 head 函数的模式打破列表

Suk*_*ann 5 haskell pattern-matching

在学习 haskell 时,我无法理解 haskell 如何自动匹配提取列表头部的模式。

head' :: [a] -> a  
head' [] = error "Can't find head in an Empty list!" 
-- How does haskell break the list into x(first) and xs(rest)? 
head' (x:xs) = x
Run Code Online (Sandbox Code Playgroud)

我读过这[1,2,3]1:2:3:[]. 那么:是一个接受任何参数并添加到右手参数的函数吗?列表是如何向后分解成两个变量 head 和 rest 的? [1,2,3] --> (x:xs)??

colon_operator :: a -> [a]
-- not sure how the function would look
Run Code Online (Sandbox Code Playgroud)

对不起,如果我不能简洁地解释我的问题,我在 haskell 方面并不是那么好。