Understanding the Haskell as-pattern

前端 未结 2 503
你的背包
你的背包 2020-12-11 08:55

I\'m reading through Real World Haskell, and am trying to understand the as-pattern.

From the book (Chapter 4):

suffixes :: [a] -> [[a]]
suffixes          


        
2条回答
  •  悲哀的现实
    2020-12-11 09:16

    xs' would be bound to the string "ello".

    xs would be bound to the string "hello".

    The @ pattern lets you give a name to a variable while also matching its structure and possibly giving name to the components.

提交回复
热议问题