Skip to content

Instantly share code, notes, and snippets.

private xxx func1(args, ..., GLOBAL) { ... func2(..., GLOBAL) ... }
private xxx func2(args, ..., GLOBAL) { ... func3(..., GLOBAL) ... }
private xxx func3(args, ..., GLOBAL) { ... func1(..., GLOBAL) ... }
public xxx func(args, ..., global) { ... func1(..., global) ... }
// "GLOBAL" representa un estado de entrada que no forma parte de
// la clase (de hecho la clase podría ser estática), porque lo que
// interesa es el proceso que realizan las funcX.
@nh2
nh2 / haskell-cucumber-syntax.feature
Created September 10, 2013 07:16
Haskell Cucumber syntax - an alternative syntax proposed for Haskell along with normal Haskell and Literate Haskell
Feature: The Data.List module
In order to be able to use lists
As a programmer
I want a module that defines list functions
Scenario: Defining the function foldl
Given I want do define foldl
Which has the type (in brackets) a to b to a (end of brackets), to a, to list of b, to a
And my arguments are called f, acc, and l
@mkhludnev
mkhludnev / q=*%3A*&wt=csv
Last active December 1, 2022 01:28
sample nested documents to demonstrate block join indexing and searching in Solr 4.5
id,_version_,BRAND_s,_root_,type_s,COLOR_s,SIZE_s
12,,,10,,Blue,XL
11,,,10,,Red,XL
10,1445176108735528960,Nike,10,parent,,
22,,,20,,Blue,XL
21,,,20,,Red,M
20,1445176108738674688,Nike,20,parent,,
32,,,30,,Blue,M
31,,,30,,Red,XL
30,1445176108740771840,Puma,30,parent,,
@palladin
palladin / gist:6270421
Created August 19, 2013 15:28
Effects and Handlers
// http://homepages.inf.ed.ac.uk/slindley/papers/handlers-draft-march2013.pdf
// Quote from the paper
// Effect handler operation clauses generalise exception handler clauses
// by adding a continuation argument, providing support for arbitrary effects. An operation
// clause is an exception clause if it ignores its continuation argument.
type Cont<'T, 'R> = Cont of ((('T -> 'R) * (exn -> 'R)) -> 'R)
type ContBuilder() =
member self.Return x = Cont (fun (k, _) -> k x)
@puffnfresh
puffnfresh / Partiality.hs
Created August 13, 2013 16:11
Partiality monad in Haskell using Free Maybe.
module Partiality where
import Control.Monad.Free
type Partiality = Free Maybe
never :: Partiality a
never = Free $ Just never
bad :: Partiality a
@visemet
visemet / code-quotes-spec.md
Created July 26, 2013 22:32
Defines the structure for the various query and update operators that are supported by MongoDB in a way that is natural to use from F#. Note that the (?) operator is only necessary for dealing with an unknown schema, rather than a user-defined class in which case (.) would provide type safety. The code quotation is traversed to construct the cor…

Intend to support all selectors and operators listed here in one form or another.

let (?) (doc : BsonDocument) (field : string) =
    unbox doc.[field]

let (?<-) (doc : BsonDocument) (field : string) value =
    doc.[field] = unbox value |> ignore
@mikkelbu
mikkelbu / gist:6084441
Created July 25, 2013 22:44
Perhaps a solution to compile FSharpxCSharp on VS10.
Following http://stackoverflow.com/questions/11123777/how-to-generate-c-friendly-net-4-0-compatible-types-using-f-3-0-type-provide I was able to compile the project using csc.exe directly by including the missing reference to fsharpx (see the full call below) and placing the dlls such that the generated .exe could find them. And the result was
[1; 2; 3]
Some(5)
The abovementioned url suggest that the problem can be solved by specifying SpecificVersion=true for the reference to FSharp.Core 4.3 (in FSharpx.Core.fsproj). I tried to do this and compiled FSharpx.Core (I had to add System.Numerics to the project though), and it seems to solve the problem. It is a bit unfortunate to be dependent on a particular version, but it seems to be the only solution at the moment.
The full call to csc.exe (on my machine)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG /reference:"C:\Program Files (x86)\Reference Assemblies\Micro
@mikkelbu
mikkelbu / gist:6082044
Last active December 20, 2015 05:59
Problems with FSharpxCSharp on VS10.
This was my approach
Downloading the dependencies via nuget, but the dependency on 'FSharp.Core' reference is marked with an error and I get the following errors and warnings if I try to compile (the first 2 are the essential ones):
Warning 1 The primary reference "FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has a higher version "4.3.0.0" than exists in the current target framework. The version found in the current target framework is "4.0.0.0". FSharpxCSharp
Warning 2 The primary reference "FSharpx.Core" could not be resolved because it has an indirect dependency on the .NET Framework assembly "FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.3.0.0" than the version "4.0.0.0" in the current target framework. FSharpxCSharp
Warning 3 The referenced component 'FSharp.Core' could not be found.
Error 4 The type or namespace name 'FSharpx' could not be f
@pthariensflame
pthariensflame / IndexedPrivilege.md
Last active November 7, 2019 10:58
An introduction to the indexed privilege monad in Haskell, Scala and C#.

The Indexed Privilege Monad in Haskell, Scala, and C#

We've already looked at two different indexed monads in our tour so far, so let's go for a third whose regular counterpart isn't as well known: the privilege monad.

Motivation

The regular privilege monad allows you to express constraints on which operations a given component is allowed to perform. This lets the developers of seperate interacting components be statically assured that other components can't access their private state, and it gives you a compile-time guarantee that any code that doesn't have appropriate permissions cannot do things that would require those permissions. Unfortunately, you cannot easily, and sometimes cannot at all, build code in the privilege monad that gains or loses permissions as the code runs; in other words, you cannot (in general) raise or lower your own privilege level, not even when it really should be a