Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I can't bind (**) operator

Tags:

f#

In f# i can easily bind (+) or (*) operators. Why can't I do the same with (**)?

> let s = (+);;
val s : (int -> int -> int)

> let f = (**);;
  let f = (**);;
  ------------^^
C:\Users\mqrx84\AppData\Local\Temp\stdin(4,13): error FS0010: Incomplete structured construct at or before this point in binding
like image 706
Grzegorz Sławecki Avatar asked Sep 12 '14 13:09

Grzegorz Sławecki


1 Answers

Because (* *) are used for multi line comments. You need to separate the parentheses from the operator with whitespace e.g. let f = ( ** );;

To define other operators that begin with *, whitespace must follow the opening parenthesis; otherwise (* is interpreted as the start of a comment: let ( *+* ) x y = (x + y)

From the spec - http://fsharp.org/specs/language-spec/

like image 159
Matthew Mcveigh Avatar answered Oct 15 '22 13:10

Matthew Mcveigh