Skip to content

Instantly share code, notes, and snippets.

Avatar

Jo Van Eyck jovaneyck

View GitHub Profile
@jovaneyck
jovaneyck / fscheck3.fsx
Last active Sep 15, 2021
FsCheck v3 breaking API, how to use in F#
View fscheck3.fsx
#r "nuget: FsCheck, version=3.0.0-beta1"
open FsCheck
open FsCheck.FSharp
let revRev xs = xs |> List.rev |> List.rev = xs
Check.QuickThrowOnFailure revRev
type Tree<'a> = Branch of Tree<'a> * Tree<'a> | Leaf of 'a
View csharp-language-ext-pipelines.cs
using System.Threading.Tasks;
using LanguageExt;
using Xunit;
namespace LanguageExtDemo
{
public class Repository
{
public OptionAsync<string> GetName(int id)
View Either.cs
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Xunit;
using LanguageExt;
using static LanguageExt.Prelude;
namespace LanguageExtDemo
{
View sharpvg-demo.fsx
#r @"C:\Code\SharpVG\SharpVG\bin\Debug\netstandard2.1\SharpVG.dll"
#r @"C:\NugetLocal\netstandard\build\net461\lib\netstandard.dll"
open SharpVG
let black = Color.ofName Black
let opaque = 1.0
let style = Style.create black black Length.one opaque opaque
let lineAt p1 p2 = Line.create (Point.ofInts p1) (Point.ofInts p2) |> Element.create |> Element.withStyle style
@jovaneyck
jovaneyck / pbt.fsx
Created Nov 17, 2018
Property-based testing in F#
View pbt.fsx
#r @"C:\NugetLocal\FsCheck.2.4.0\lib\net45\FsCheck.dll"
open FsCheck
//Simple property
let reversingAReversedList l = List.rev (List.rev l) = l
Check.Quick reversingAReversedList
//Failing property: example of standard shrinking
let reversingAList l = (List.rev l) = l
Check.Quick reversingAList
@jovaneyck
jovaneyck / peano.pl
Created Nov 15, 2018
Peano arithmetic as an introduction to prolog
View peano.pl
%load a prolog file like [this].
%or just send file to REPL
%Peano arithmetic
% https://en.wikipedia.org/wiki/Peano_axioms
% * 0 is a natural number
% * if n is a natural number, s(n) is a natural number
% * equality
% * 0 = 0
% * a = b -> s(a) = s(b)
@jovaneyck
jovaneyck / gist:444fd6c39933ce9b5984f06d9193179a
Last active May 25, 2018
GivenWhenThen hierarchy abuse example. Try to investigate failure of WhenTargetContractDoesNotCorrespondToSourceContractOtherFirmnessLevel.ThenRuleShouldFail()
View gist:444fd6c39933ce9b5984f06d9193179a
[TestClass]
public class WhenTargetContractDoesNotCorrespondToSourceContractOtherFirmnessLevel : GivenRulesDeterminedFromDatabaseConfiguredRules
{
private ICapacityConversionRequest capacityConversionRequest;
private IRepository<ITransmissionService> transmissionServiceRepository;
private void GivenParameters()
{
this.capacityConversionRequest = MockRepository.GenerateStub<ICapacityConversionRequest>();
@jovaneyck
jovaneyck / code-kata-workshop.md
Last active Feb 13, 2020
Code kata workshop - links
View code-kata-workshop.md
@jovaneyck
jovaneyck / notes.md
Last active Jan 18, 2018
Kennis & Pasta - Test pyramid
View notes.md
@jovaneyck
jovaneyck / rover.fsx
Last active Nov 11, 2017
Playing around with functional calisthenics and property-based testing on the Mars Rover kata
View rover.fsx
type Direction = North | East |South | West
type Location = { x : int; y : int}
type Rover = { Location : Location; Direction : Direction}
let createRover location direction = {Location = location; Direction = direction}
type Command =
| Forward
| Backward
| TurnLeft