Skip to content

Instantly share code, notes, and snippets.

View jovaneyck's full-sized avatar

Jo Van Eyck jovaneyck

View GitHub Profile
@jovaneyck
jovaneyck / code-kata-workshop.md
Last active September 5, 2023 07:10
Code kata workshop - links
@jovaneyck
jovaneyck / swaggerprovider-demo.fsx
Created May 6, 2023 14:47
An example on how to use SwaggerProvider: a type provider that automatically generates strongly-typed clients for openapi REST api's
//https://fsprojects.github.io/SwaggerProvider/#/
(*
#r "nuget: SwaggerProvider, Version=2.0.0-beta9"
*)
open SwaggerProvider
open System
open System.Net.Http
type PetStore = OpenApiClientProvider<"https://petstore3.swagger.io/api/v3/openapi.json">
@jovaneyck
jovaneyck / binarysearchtree-properties.fsx
Last active October 2, 2022 10:43
Example properties for a binary search tree implementation
//Inspired on "How to specify it!" by John Hughes (& Java adaptation by Johannes Link)
//https://johanneslink.net/how-to-specify-it/
#r "nuget: fscheck"
open FsCheck
module BST =
type BinarySearchTree<'v> =
| Empty
| Node of
@jovaneyck
jovaneyck / peano.pl
Created November 15, 2018 21:31
Peano arithmetic as an introduction to prolog
%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 / fscheck3.fsx
Last active September 15, 2021 11:55
FsCheck v3 breaking API, how to use in F#
#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
using System.Threading.Tasks;
using LanguageExt;
using Xunit;
namespace LanguageExtDemo
{
public class Repository
{
public OptionAsync<string> GetName(int id)
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Xunit;
using LanguageExt;
using static LanguageExt.Prelude;
namespace LanguageExtDemo
{
#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 November 17, 2018 15:50
Property-based testing in F#
#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 / gist:444fd6c39933ce9b5984f06d9193179a
Last active May 25, 2018 13:01
GivenWhenThen hierarchy abuse example. Try to investigate failure of WhenTargetContractDoesNotCorrespondToSourceContractOtherFirmnessLevel.ThenRuleShouldFail()
[TestClass]
public class WhenTargetContractDoesNotCorrespondToSourceContractOtherFirmnessLevel : GivenRulesDeterminedFromDatabaseConfiguredRules
{
private ICapacityConversionRequest capacityConversionRequest;
private IRepository<ITransmissionService> transmissionServiceRepository;
private void GivenParameters()
{
this.capacityConversionRequest = MockRepository.GenerateStub<ICapacityConversionRequest>();