Skip to content

Instantly share code, notes, and snippets.

@nyaray
Created November 1, 2019 13:40
Show Gist options
  • Save nyaray/3112c0300e42732f3241d138c7431770 to your computer and use it in GitHub Desktop.
Save nyaray/3112c0300e42732f3241d138c7431770 to your computer and use it in GitHub Desktop.
Explaining parts of F#
let mergeStrings a b c = // string -> (string -> (string -> string))
a + b + c
let test = mergeStrings "foo" "bar"
printfn "%A" (test "kalle")
printfn "%A" ("foo", 2)
//[<CLIMutable>]
type Dep = {
getIt : string -> string
kind : string
}
with
member this.getKind = this.kind
type Dep
with
member this.getConstant = 3
let doWork (d: Dep) param : string =
d.getConstant |> printfn "herro %d"
printfn "%A" d
d.getIt param
let work =
doWork {
getIt = fun x -> "I am dep. You are: " + x
kind = "hardcoded" }
work "teh win"
|> (printfn "work result: %s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment