%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
FSharp eye for the Haskell guy - London 2015
1. F# eye for the Haskell weenie
Phillip Trelford, @ptrelford
London Haskell, 2015
2. F#
• Statically Typed
• Functional First
• Object Oriented
• Open Source
• Cross Platform
• In Visual Studio
& Xamarin Studio
& Emacs & Vim & Atom & ..
3. F# Influences
// OCaml + Python like light syntax
let dist (x1,y1) (x2,y2) =
let x = x1 - x2 in
let y = y2 - y1 in
sqrt (x * x + y * y)
// & C# dot-driven development
let trim (s:string) =
s.Trim() F#
OCaml
Python
C#
4. Miranda Haskell
Haskell
Miranda
Type
Classes
Monads
Change of syntax for type declarations
— Miranda
bool ::= True | False
string == [char]
becomes in Haskell
data Bool = False | True
type String = [Char]
Some History of Functional Programming Languages, Turner
7. F# Software Foundation
http://www.fsharp.org
software stacks
trainings teaching F# user groups snippets
mac and linux cross-platform books and tutorials
F# community open-source MonoDevelop
contributions research support
consultancy mailing list
8. F# Testimonials
order of magnitude increase in productivity
GameSys
performance is 10× better than the C++ that it replaces
Aviva
I am still waiting for the first bug to come in
E-On
Source: fsharp.org/testimonials
11. Live Demos: Bread & Butter stuff
Phil Trelford, @ptrelford
F# eye for the Haskell weenie
12. Functions
let rec fact x =
if x < 1 then 1
else x * fact (x - 1)
let rec fib = function
| 0 -> 0 | 1 -> 1
| n -> fib(n - 1) + fib(n - 2)
[1..3] |> List.map ((+)1)
let inline map xs = List.map xs
map ((+)1) [1..3]
13. Sum types
Type definition
type Shape =
| Circle of radius:float
| Rectangle of width:float * height:float
Pattern matching
match shape with
| Circle(r) -> 2.0 * r
| Rectangle(_, h) -> h
14. Active Patterns
let (|FormulaText|_|) (s:string) =
if s.StartsWith "=" then Some(s.Substring(1))
else None
let (|NumberValue|_|) (s:string) =
match System.Decimal.TryParse(s) with
| true, n -> Some(n)
| false, _ -> None
let parse = function
| FormulaText text -> Formula text
| NumberValue n -> Number n
| _ -> invalidOp "Unexpected text"
17. Turtle Computation Expression
let british = turtle {
LIFT THE PEN UP
WALK 4 STEPS
TURN 3 GRADATIONS TO THE RIGHT
PICK THE GREEN PEN
PUT THE PEN DOWN
DO AS leonardo
LIFT THE PEN UP
WALK 4 STEPS
PICK THE RED PEN
PUT THE PEN DOWN
REPEAT 3 TIMES WHAT leonardo DOES
}
21. Pointless free programming
let step dir mario =
mario |> physics |> walk dir |> gravity |> jump dir
let step dir =
physics >> walk dir >> gravity >> jump dir
22. Live Demos: Type Providers
Phillip Trelford, @ptrelford
London Haskell, 2015
23. Type providers: JSON
open FSharp.Data
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let simple = Simple.GetSample()
simple.Age
“extreme confidence in their own productivity is a hallmark of LISP Weenies and Insufferable Haskell Pricks”- http://sdtimes.com/code-watch-functional-programmings-smugness-problem/#ixzz3sL5eeHWo
https://www.quora.com/Why-is-Haskell-considered-such-a-nice-and-great-language-yet-is-not-being-used
https://www.quora.com/Functional-Programming/Which-of-Haskell-and-OCaml-is-more-practical