+--------------------+--------------------+-------------------------+--------------------+
|Operation | F#+ / F# |F#+ Haskell Compatibility|Haskell |
+====================+====================+=========================+====================+
|List.append | @ | | ++ |
+--------------------+--------------------+-------------------------+--------------------+
|Function composition| f << g | f . (g) | f . g |
+--------------------+--------------------+-------------------------+--------------------+
| | <| | $ | $ |
+--------------------+--------------------+-------------------------+--------------------+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"C:\packages\FsControl.1.0.8\lib\net40\FsControl.Core.dll" | |
type Eval = Eval of int | |
let eval (Eval x) = x | |
// To define a Type Method we need to add at least 2 instances | |
type Eval' = Eval' of int | |
let eval' (Eval' x) = x | |
module ExpAlg = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"c:/packages/FsControl.1.0.9/lib/net40/FsControl.Core.dll" | |
open FsControl.Core.TypeMethods | |
open FsControl.Core.Types | |
open FsControl.Operators | |
type MonadBuilder() = | |
member inline b.Return(x) = result x | |
member inline b.Bind(p,rest) = p >>= rest | |
member b.Let (p,rest) = rest p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"bin\Debug\FsControl.Core.dll" // from https://github.com/gmpl/FsControl | |
let inline return' x = Inline.instance FsControl.Core.TypeMethods.Applicative.Pure x | |
let inline (>>=) x (f:_->'R) : 'R = Inline.instance (FsControl.Core.TypeMethods.Monad.Bind, x) f | |
let inline mzero () = Inline.instance FsControl.Core.TypeMethods.MonadPlus.Mzero () | |
let inline mplus (x:'a) (y:'a) : 'a = Inline.instance (FsControl.Core.TypeMethods.MonadPlus.Mplus, x) y | |
module Monad = | |
open FsControl.Core.TypeMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FUNCTORS AND APPLICATIVES | |
//-------------------------- | |
// You may run this script step-by-step | |
// The order of execution has to be respected since there are redefinitions of functions and operators | |
// -------- | |
// FUNCTORS | |
// -------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Namespaces | |
TryParsers | |
WebLinq | |
WebLinq.Collections | |
WebLinq.Html | |
WebLinq.Sys | |
WebLinq.Text | |
WebLinq.Xml | |
WebLinq.Xsv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r @"c:/packages/FSharpPlus.1.0.0-CI00099/lib/net45/FSharpPlus.dll" | |
open System | |
open FSharpPlus | |
// Validation definition | |
type Validation<'a,'e> = Success of 'a | Failure of 'e | |
with | |
// Validation is an instance of Applicative | |
static member inline Return x = Success x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type A = class end | |
type B = class inherit A end | |
type C = class inherit B end | |
type D = class inherit C end | |
type IsNull = | |
inherit D | |
static member inline ($) (_:A , x :'a when 'a : not struct) = System.Object.ReferenceEquals(x, null) | |
static member inline ($) (_:B , x :'a when 'a : null ) = match x with null -> true | _ -> false | |
static member inline ($) (_:C , _:D) = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#load @".paket\load\net452\FSharpPlus.fsx" | |
open FSharpPlus | |
open System | |
[<AutoOpen>] | |
module SideEffects = | |
let private r = Random() | |
let printLn text = async { printfn "%s" text } | |
let readLn() = async { return Console.ReadLine() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nowarn "0042" | |
let inline retype (x: 'T) : 'U = (# "" x: 'U #) | |
open System | |
type Curry = | |
static member inline Invoke f = | |
let inline call_2 (a: ^a, b: ^b) = ((^a or ^b) : (static member Curry: _*_ -> _) b, a) | |
call_2 (Unchecked.defaultof<Curry>, Unchecked.defaultof<'t>) (f: 't -> 'r) : 'args |
OlderNewer