G4143
G4143

Reputation: 2829

Elm: let binding and type annotations with tuples

How would I apply type annotations for the code snippet below? Note: e and r are List Tree's.

let
  {--what is the type annotation here for the tuple (e, r)?--}
  ( e, r ) = List.partition (\(Node a _) -> a == (toString c)) lt
in....

Upvotes: 0

Views: 410

Answers (1)

Chad Gilbert
Chad Gilbert

Reputation: 36375

What you have there is a destructuring statement, and cannot have a type annotation.

Type annotations are for named functions or values. For example:

plus : Int -> Int -> Int
plus = (+)

year : Int
year = 2017

Your destructuring of (e, r) is not a named function. It merely introduces two new values to the scope, e and r.

Upvotes: 5

Related Questions