I've looked a number of sources: it seems not possible to declare a type definition in F# ala Haskell:
' haskell type def: myFunc :: int -> int
I'd like to use this type-def style in F#--FSI is happy to echo back to me:
fsi> let myType x = x +1;; val myType : int -> int
I'd like to be explicit about the type def signature in F# as in Haskell. Is there a way to do this? I'd like to write in F#:
//invalid F# myFunc : int -> int myFunc x = x*2
The usual way is to do let myFunc (x:int):int = x+1
.
If you want to be closer to the haskell style, you can also do let myFunc : int -> int = fun x -> x+1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With