SlideShare a Scribd company logo
F#function theory
F#type inference
//Brackets aren't mandatory:let f(x,y) = x+ylet f x y  = x+y
//Function type:let I x = x//    x: 'a//    I: 'a -> 'a
//Example 2:let K x y = x//      x: 'a//      y: 'b//      K: 'a -> 'b -> 'a
//Partial applicationlet constHi = K "Hello"let hi = constHi 123val constHi : (int -> string)//hi : string ="Hello"
//Example 3:let S x y z = x(z)(y(z))//        x:  f(a  b)//        x:  a -> b -> c//        z:  a//        y:  a -> bS x y z: (a -> b -> c) -> (a -> b) -> a -> c
//Exercise: What are these functions?val it : (('a -> 'b) -> 'a list -> 'b list)val it : (('a -> 'b -> 'a) -> 'a -> 'b list -> 'a)val it : ('a * 'b -> 'a)
f(g(x))F#function composition
//function compositionlet combine f g x = g(f(x)) Let combine f g x = (f>>g)x//        f:  'a -> 'b//        g:  'b -> 'c//        x:  'acombine f g x: (a -> b) -> (b -> c) -> a -> c
//You can remove the parameter from the last one!let combine f g= (f>>g)// combine: ('a -> 'b) ->            ('b -> 'c) ->            ('a -> 'c)
     result: generic abstraction   whitout re-        ference to concrete              typeslet handle = (save >> validate >> send)
F#monads
thought behind LINQ“list monad”IEnumerable<T>“maybe monad”Nullable<T>…
three types of operations1.3.'a -> M<’a>M<'a> -> 'b2.M<'a> -> M<'b>
typical example2.M<'a> -> ('a -> M<'b>) -> M<'b>3.M<'a> -> 'b -> ('b -> 'a -> 'b) -> 'b
F#combinators
S- K- I- combinatorsLike we started:I x = xK x y = xS x y z =    x z (y z)
y-combinatorf(x) when x=f?f(f) = f  and  f=f(f)f(g) = g(f(g))Y = S (K (S I I)) (S (S (K S) K) (K (S I I)))
references / linkshttp://en.wikipedia.org/wiki/SKI_combinator_calculushttp://en.wikipedia.org/wiki/Fixed_point_combinatorhttp://community.bartdesmet.net/blogs/bart/archive/2009/08/17/mis-using-c-4-0-dynamic-type-free-lambda-calculus-church-numerals-and-more.aspxhttp://blogs.msdn.com/b/madst/archive/2007/05/11/recursive-lambda-expressions.aspxhttp://www.madore.org/~david/programs/unlambda/http://channel9.msdn.com/Shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monadshttp://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Greg-Meredith-Monadic-Design-Patterns-for-the-Web-Introduction-to-Monadshttp://blogs.msdn.com/b/wesdyer/archive/2008/01/11/the-marvels-of-monads.aspxhttp://channel9.msdn.com/Shows/Going+Deep/Bart-De-Smet-MinLINQ-The-Essence-of-LINQhttp://ttic.uchicago.edu/~dreyer/course/papers/wadler.pdfhttp://www.meetup.com/FSharpHelsinki/messages/boards/forum/1395955

More Related Content

DOC
Infix to-postfix examples
PDF
Shortcuts JAVA
PPT
PPTX
JavaScript WTFs
ZIP
Haskell Jumpstart
PDF
Instaduction to instaparse
PDF
Preprocessor Programming
Infix to-postfix examples
Shortcuts JAVA
JavaScript WTFs
Haskell Jumpstart
Instaduction to instaparse
Preprocessor Programming

What's hot (17)

PPT
Circular queues
PPT
About Go
PPT
Computer notes - Recursive
PPT
computer notes - Data Structures - 14
PPTX
My lecture infix-to-postfix
PDF
05 Jo P May 07
PDF
Applications of stack
PDF
re3 - modern regex syntax with a focus on adoption
PDF
Netbeans keyboard shortcut
PPTX
PROLOG: Cuts And Negation In Prolog
PDF
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
PDF
Nobody knows-except-g4mm4
PDF
Introduction to Compiler Development
PDF
conditional
PDF
Perl 5.10 on OSDC.tw 2009
PPTX
C Best and Worst Practices in Embedded
PPT
Lecture 3 c++
Circular queues
About Go
Computer notes - Recursive
computer notes - Data Structures - 14
My lecture infix-to-postfix
05 Jo P May 07
Applications of stack
re3 - modern regex syntax with a focus on adoption
Netbeans keyboard shortcut
PROLOG: Cuts And Negation In Prolog
printf("%s from %c to Z, in %d minutes!\n", "printf", 'A', 45);
Nobody knows-except-g4mm4
Introduction to Compiler Development
conditional
Perl 5.10 on OSDC.tw 2009
C Best and Worst Practices in Embedded
Lecture 3 c++
Ad

Similar to Function therory (20)

PPTX
Qcon2011 functions rockpresentation_f_sharp
PPTX
Qcon2011 functions rockpresentation_f_sharp
PDF
F# and Reactive Programming for iOS
PPT
Getting the MVVM Kicked Out of Your F#'n Monads
PPTX
Sharper tools with F#
PPTX
Functional programming with FSharp
PPT
F# and the DLR
PDF
Functional Programming in F#
ODP
F# 101
PDF
Cross platform native development in f#
PPTX
F# intro
DOCX
In the Notes on Programming Language Syntax page, an example par.docx
PPTX
F# Presentation
PPTX
Combinators, DSLs, HTML and F#
PPTX
F sharp _vs2010_beta2
PDF
The Fuss about || Haskell | Scala | F# ||
PDF
Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
PPTX
.Net (F # ) Records, lists
PDF
Functional programming with F#
PDF
An introduction to functional programming with Swift
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharp
F# and Reactive Programming for iOS
Getting the MVVM Kicked Out of Your F#'n Monads
Sharper tools with F#
Functional programming with FSharp
F# and the DLR
Functional Programming in F#
F# 101
Cross platform native development in f#
F# intro
In the Notes on Programming Language Syntax page, an example par.docx
F# Presentation
Combinators, DSLs, HTML and F#
F sharp _vs2010_beta2
The Fuss about || Haskell | Scala | F# ||
Stanfy MadCode Meetup #9: Functional Programming 101 with Swift
.Net (F # ) Records, lists
Functional programming with F#
An introduction to functional programming with Swift
Ad

More from Tuomas Hietanen (14)

PPTX
Blockchain (using NBitcoin and FSharp)
PPTX
Machine learning (using Accord.NET and FSharp)
PPTX
Possible FSharp Refactorings could be...
PPTX
Message passing & NoSQL (in English)
PPTX
The Pain Points of C#
PPTX
F# references (and some misc slides)
PPTX
Linq in practice
PPTX
Using f# project from c#
PPTX
Funktioteoriaa
PPTX
Pari sekalaista diaa ja F#-Referenssejä
PPTX
F# ja C# yhteiskäyttö
PPTX
C# nykyiset kipupisteet
PPTX
LINQ käytännössä
PDF
Coding with LINQ, Patterns & Practices
Blockchain (using NBitcoin and FSharp)
Machine learning (using Accord.NET and FSharp)
Possible FSharp Refactorings could be...
Message passing & NoSQL (in English)
The Pain Points of C#
F# references (and some misc slides)
Linq in practice
Using f# project from c#
Funktioteoriaa
Pari sekalaista diaa ja F#-Referenssejä
F# ja C# yhteiskäyttö
C# nykyiset kipupisteet
LINQ käytännössä
Coding with LINQ, Patterns & Practices

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Function therory

Editor's Notes

  • #9: When functions don’t have side effects we can actually define what they do (and correctness) purely by looking the types.
  • #10: “function composition”: To combine two functions into a new one.“For X, first apply g, then f.”, Or “f of g of x”
  • #13: No stiffness of object-oriented programming Possibility to make top-down design
  • #14: Often we want to combine things that are not so directly linked to each other… Monad term is from Haskell where it is actually the only way to make side effects
  • #15: Actually Nullable&lt;T&gt; is just a list with zero or one items.
  • #16: Add things to thedomainModify: Handle the domainGet items from the domain
  • #17: 2: (a -&gt; M&lt;b&gt;) is a transformation function (formap/select/…)3: (b -&gt; a -&gt; b) function is a collector/selector function and b is kind of an accumulator to collect the output result.
  • #19: By chaining these we can create anything (without named parameters) I is unnecessary as I 5 = S (K) (K) (5) One ”Church-man&quot; e.g. proved that we can make numbers and boolean logic just with functions. There is even a programming language based only combining these functions.
  • #20: What if f(x) function would get input itself, I mean the f? Will become an recursion and infinite loop… The loop and the ending-condition-function can be separated to different functions Y can of course be made just with SKI-calculus