syntax - What does the "@" symbol mean in reference to lists in Haskell? -


i've come across piece of haskell code looks this:

ps@(p:pt) 

what @ symbol mean in context? can't seem find info on google (it's unfortunately hard search symbols on google), , can't find function in prelude documentation, imagine must sort of syntactic sugar instead.

yes, it's syntactic sugar, @ read aloud "as". ps@(p:pt) gives names

  1. the list: ps
  2. the list's head : p
  3. the list's tail: pt

without @, you'd have choose between (1) or (2):(3).

this syntax works constructor; if have data tree = tree [tree a], t@(tree _ kids) gives access both tree , children.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -