Skip to content

Instantly share code, notes, and snippets.

@eulerfx
eulerfx / AsyncSeqVsScalaz-stream.md
Last active March 4, 2016 21:48
Informal proof that F# AsyncSeq is equal in expressive power to scalaz-stream Process when specialized to Task

There is a great purely functional streaming/IO library in Scala called scalaz-stream. It is itself based upon a Haskell library called machines. They provide powerful abstractions to express compositional effectful computations. These libraries rely on certain type system features in both Scala and Haskell which are unavailable in F# - namely existential types and higher kinds. Higher kinds allow the monad representing the side-effects to be abstracted over. If however we specialize this to a specific monad, we can get around the lack of existentials as well.

Tomas Petricek created a type called asynchronous sequence which provides similar capabilities. The F# AsyncSeq type is declared as follows:

type AsyncSeq<'a> = Async<AsyncSeqInner<'a>>

and AsyncSeqInner<'a> = 
    | Nil
 | Cons of 'a * AsyncSeq&lt;'a&gt;
@sevastos
sevastos / docker-mongo-virtualbox.md
Last active December 3, 2022 10:11
Boot2Docker (VirtualBox) MongoDB volume filesystem issue

Journey

I was using Boot2Docker 1.2 (OSX) and wanted to use volume for MongoDB. First nothing was happening because 1.2 has no Guest Additions and volumes don't work. There is a workaround by making a boot2docker.iso from master which has Guest Additions.

But then Mongo didn't like putting data on VirtualBox's shared folders:

[initandlisten] 	WARNING: This file system is not supported. For further information see:
[initandlisten] http://dochub.mongodb.org/core/unsupported-filesystems
"I prefer passing simple data to passing functions (codata). Simpler
to reason and to test with *Check."
Yo aún no lo se, en función del problema a resolver quizás deba pasar
una función o no. En todo caso, esperaré que mi función tenga las más
propiedades deseables posibles.
"I prefer functions with small domains."
Yo no, yo prefiero funciones con grandes dominios.
scala> def foo[R <: { def f1: Int }](x: R): (R, Int) = (x, x.f1)
foo: [R <: AnyRef{def f1: Int}](x: R)(R, Int)
scala> val x = new {
| def f1 = 90
| def f2 = "hello"
| }
x: AnyRef{def f1: Int; def f2: String} = $anon$1@adeb0ee
scala> foo(x)._1.f2
@colinbull
colinbull / gist:4ec846e146f4ca15f3e1
Last active August 29, 2015 14:06
SqlProvider with ComposableQuery
open System
open FSharp.Data.Sql
open FSharpComposableQuery
FSharp.Data.Sql.Common.QueryEvents.SqlQueryEvent |> Event.add (printfn "Executing SQL: %s")
type HR = SqlDataProvider<ConnectionStringName = "***********", DatabaseVendor = Common.DatabaseProviderTypes.ORACLE>
let ctx = HR.GetDataContext()
type AuditRecord = {
@bvenners
bvenners / gist:67cb4e8c0b285ca99fa3
Last active August 29, 2015 14:05
Getting a Scala compiler error when needed typeclass coherency is missing
scala> import org.scalactic._
import org.scalactic._
scala> val lower = EquiSets[String](StringNormalizations.lowerCased.toHashingEquality)
lower: org.scalactic.EquiSets[String] = EquiSets(NormalizingHashingEquality(lowerCased))
scala> val trimmed = EquiSets[String](StringNormalizations.trimmed.toHashingEquality)
trimmed: org.scalactic.EquiSets[String] = EquiSets(NormalizingHashingEquality(trimmed))
scala> val hiho = lower.EquiSet("hi", "ho")
package com.rr.experiment
import org.specs2.ScalaCheck
import org.specs2.mutable._
import org.scalacheck._
import scalaz._
import scodec._
module ATComposeProductSum where
import Control.Applicative
import Data.Traversable
import Data.Functor.Compose
import Data.Functor.Product
import Data.Functor.Sum
import Data.Functor.Identity
@sayedihashimi
sayedihashimi / transform-xml.ps1
Last active January 17, 2024 20:02
Script which can be used to transform an XML file using XDT. All you need to do is download the script and call it. The script will download the files it needs to run.
#!/usr/bin/env powershell
<#
.SYNOPSIS
You can use this script to easly transform any XML file using XDT.
To use this script you can just save it locally and execute it. The script
will download its dependencies automatically.
Created by sayediHashimi
Modified by obscurerichard
Thanks Stack Overflow: https://stackoverflow.com/questions/8989737/web-config-transforms-outside-of-microsoft-msbuild
@eulerfx
eulerfx / JsonValueCodecSyntax.fs
Created June 23, 2014 21:51
F# FSharp.Data.JsonValue codec syntax
/// port of https://github.com/mausch/Fleece
type ToJsonClass = ToJsonClass
type FromJsonClass = FromJsonClass
type ParseResult<'a> = Choice<'a, string>
module ParseResult =