Functional Programming – Epilogue

Functional Datastructures

Credit:  (Chris Okasaki, Cambridge)

  • Key Concept: Lazy Rebuilding means we only rebuild the diff and only when we need it as in LWP copy on write

datastructures

datastructures2

 

 

Scala, F#, Ocaml Pattern Matching Type Inference Exhaustiveness Guarantees

First contender: Scala

patternscala

In true keeping with a dynamic platform, Scala does not infer there is a problem until runtime.

Next contender: F#

patternfsharp

 

F# improves over Scala by catching the problem at compile time.

In this simple example, what is missing may be obvious. More complex examples may be harder to infer.

Final contender: OCaml

patternocaml

OCaml catches the problem at compile time and indeed infers the missing match. This is a clear improvement over F#.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s