0

This code seems to use the @ symbol to annotate a function signature, seemingly using it to save the type into a variable?

https://github.com/hlian/mathbot/blob/master/web/src/Main.hs#L63

mathbot cmd@(Just (Command "math" user channel (Just text)))

Attempting to use a similar syntax results in parse error on input ‘@’.

Does this do what I think it does? And if so where is it defined come from? And how does one define a function that can operate within a type signature?

Abraham P
  • 15,029
  • 13
  • 58
  • 126
  • 3
    That's not a type annotation, that's a pattern. The whole thing is called an "as pattern". – Carl Jul 11 '16 at 13:07
  • Always include all relevant code. The GitHub code might get deleted. – Zeta Jul 11 '16 at 13:15
  • 1
    You don't "save the type into a variable", that's nonsense. And what is a "function that can operate within a type signature"? (That would seem to speak about dependent types, but I believe you may be referring to entirely something else...) – chi Jul 11 '16 at 13:16

0 Answers0