Skip to content

oldgittroy/FPLabs

Repository files navigation

FPLabs

Functional programming labs for C#/LINQ, F#, and JS

Welcome to Troy's functional programming labs prepared for the North Dallas .NET User Group. In these labs we will explore the concepts behind functional programming and apply them using C#, JavaScript, and F#.

Warning: not all of the code in the examples will compile. Sometimes this is deliberate, sometimes I just say its deliberate!

Why Do We Care?

  • About doing more with less code
  • Most FP code has 2x to 10x fewer lines of code than OOP

Other Reasons We Care

  • Microservices
  • Big Data
  • Search
  • Collections
  • Research
  • Startups
  • All the cool kids are doing it

Where did this come from?

Generations of Computing


What happens when you code using FP

Even Neil DeGrasse Tyson gives you respect!


the basics...

Lists, Collections, Oh My!

data


Abstraction = Using Functions

f(x)

  • OOP abstracts low level operations into classes.
  • FP abstracts away things like loops and interfaces

Most .NET developers already use some aspects of FP in tools such as LINQ, arrow functions, collections, etc

Expressions

expr

Immutablity

Pure functions

  • No side effects
  • Returns the same output for the same input (singleton)

immutable

  • Static functions = singletons
  • Most complexity and bugs in an application are a result of pervasive use of state and side effects of stateful code
  • Encapsulation

Anonymous Functions

Delegates

Lambdas

()=>
  =>

Func<T,Tresult>

Pure Function Lab


Levels of Abstraction

1. Abstraction level 0: no functions

  1. Abstraction Level 1: First Order Functions

  2. Abstraction Level 2: Higher Order Functions + Combinator Libraries

  3. Abstraction Level 3: Typeclasses, Abstracting over Combinator Libraries

  4. Abstraction Level 4: Abstracting over Typeclasses


The languages

Best F# Intro Ever

Level 3 Functional Programming Site

Resources

Programming without IFs

Advanced Labs

Create your own big data processor with map/reduce

About

Funcitonal programming labs for C#/LINQ, F#, and JS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published