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
- the list:
ps
- the list's head :
p
- 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
Post a Comment