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
// The problem with Run is that the expression is begin rebuilt and then compiled everytime, potentially too expensive | |
let Run : int -> int = fun y -> Query.range(0,1000) | |
|> Query.filter(fun x -> x > y) | |
|> Query.sum | |
|> Query.run | |
// The problem with BuildFunc is that it doesn't compile :) | |
let BuildFunc : int -> int = Query.range(0,1000) | |
|> Query.filter(fun x -> x > VAR) // VAR should be the input parameter to the compiled func | |
|> Query.sum | |
|> Query.compile |
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 Value = | |
| NoValue | |
| Bool of bool | |
| Int of int | |
| String of string | |
| Double of double | |
| Void | |
// With interpreters it's often good to have a stack of variables | |
// For instance when the interpreter calls a function typically a stackframe is pushed |
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
// I like to create class type that accepts a generic enhancer function | |
// I tried 3 variants and nothing gives me the result I need | |
// Anyone has any ideas? | |
// warning FS0064: This construct causes code to be less generic than indicated by | |
// the type annotations. The type variable 'U has been constrained to be type 'obj'. | |
type MyTest1<'T>(enhancer : 'U->'U) = | |
let whatever = 3 | |
type MyTest2<'T>() = |
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
// A flowlet sample of simple customer registration flow | |
// First let's declare some types to hold the registration info | |
type AddressInfo = | |
{ | |
FirstName : string | |
LastName : string | |
CareOf : string | |
AddressLine1 : string | |
AddressLine2 : string |
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
// ---------------------------------------------------------------------------------------------- | |
// Copyright (c) Mårten Rånge. | |
// ---------------------------------------------------------------------------------------------- | |
// This source code is subject to terms and conditions of the Microsoft Public License. A | |
// copy of the license can be found in the License.html file at the root of this distribution. | |
// If you cannot locate the Microsoft Public License, please send an email to | |
// dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
// by the terms of the Microsoft Public License. | |
// ---------------------------------------------------------------------------------------------- | |
// You must not remove this notice, or any other, from this software. |
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
open Microsoft.FSharp.Core | |
open System | |
open System.Reflection | |
let mutable errors = 0 | |
let print (cc : ConsoleColor) (prefix : string) (msg : string) : unit = | |
let old = Console.ForegroundColor | |
try |
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
#define COPY_MOVE(type) \ | |
type (type const &) = default; \ | |
type (type &&) = default; \ | |
type & operator= (type const &) = default; \ | |
type & operator= (type &&) = default; | |
template<std::size_t> | |
struct my_tuple_index | |
{ | |
}; |
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
// ---------------------------------------------------------------------------------------------- | |
// Copyright (c) Mårten Rånge. | |
// ---------------------------------------------------------------------------------------------- | |
// This source code is subject to terms and conditions of the Microsoft Public License. A | |
// copy of the license can be found in the License.html file at the root of this distribution. | |
// If you cannot locate the Microsoft Public License, please send an email to | |
// dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
// by the terms of the Microsoft Public License. | |
// ---------------------------------------------------------------------------------------------- | |
// You must not remove this notice, or any other, from this software. |
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
// ---------------------------------------------------------------------------------------------- | |
// Copyright (c) Mårten Rånge. | |
// ---------------------------------------------------------------------------------------------- | |
// This source code is subject to terms and conditions of the Microsoft Public License. A | |
// copy of the license can be found in the License.html file at the root of this distribution. | |
// If you cannot locate the Microsoft Public License, please send an email to | |
// dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
// by the terms of the Microsoft Public License. | |
// ---------------------------------------------------------------------------------------------- | |
// You must not remove this notice, or any other, from this software. |
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
// ---------------------------------------------------------------------------------------------- | |
// Copyright (c) Mårten Rånge. | |
// ---------------------------------------------------------------------------------------------- | |
// This source code is subject to terms and conditions of the Microsoft Public License. A | |
// copy of the license can be found in the License.html file at the root of this distribution. | |
// If you cannot locate the Microsoft Public License, please send an email to | |
// dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound | |
// by the terms of the Microsoft Public License. | |
// ---------------------------------------------------------------------------------------------- | |
// You must not remove this notice, or any other, from this software. |
OlderNewer