Skip to content

Instantly share code, notes, and snippets.

View wallymathieu's full-sized avatar

Oskar Gewalli wallymathieu

View GitHub Profile
@wallymathieu
wallymathieu / onion-1.fs
Last active September 20, 2022 19:32 — forked from akhansari/onion-1.fs
F# : Onion architecture in a nutshell
// 1. pure, don't think about IO at all
module Domain =
let add x y = x + y
// 2. think about IO but not its implementation
module App =
let add (getX: unit -> Async<int32>) y =
async {
let! x = getX ()
return Domain.add x y
@wallymathieu
wallymathieu / Program.fs
Created December 27, 2021 10:30
Typeprovider issue
open FSharpPlus
open FSharpPlus.TypeLevel
let x = TypeNat<2>.Value
// For more information see https://aka.ms/fsharp-console-apps
printfn "Hello from F#"
@wallymathieu
wallymathieu / coverage.cobertura.xml
Created June 13, 2020 06:32
Coverage report 2020-06-13 F#+
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.1306" branch-rate="0.0974" version="1.9" timestamp="1592029460" lines-covered="512" lines-valid="3919" branches-covered="343" branches-valid="3519">
<sources>
<source>/Users/mathieu/src/fs/FSharpPlus/src/FSharpPlus/</source>
</sources>
<packages>
<package name="FSharpPlus" line-rate="0.1306" branch-rate="0.0974" complexity="5733">
<classes>
<class name="FSharpPlus.Internals.Id`1" filename="Internals.fs" line-rate="0" branch-rate="1" complexity="2">
@wallymathieu
wallymathieu / coverage.cobertura.xml
Created June 13, 2020 06:32
Coverage report 2020-06-13 F#+
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.1306" branch-rate="0.0974" version="1.9" timestamp="1592029460" lines-covered="512" lines-valid="3919" branches-covered="343" branches-valid="3519">
<sources>
<source>/Users/mathieu/src/fs/FSharpPlus/src/FSharpPlus/</source>
</sources>
<packages>
<package name="FSharpPlus" line-rate="0.1306" branch-rate="0.0974" complexity="5733">
<classes>
<class name="FSharpPlus.Internals.Id`1" filename="Internals.fs" line-rate="0" branch-rate="1" complexity="2">
@wallymathieu
wallymathieu / Trying-out-fleece.ipynb
Created May 24, 2020 15:12
Problem with microsoft.dotnet-interactive/1.0.115407 dotnet 5.0.100-preview.4.20258.7
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[AttributeUsage(System.AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public class ಠ_ಠAttribute : Attribute
{
public ILog Log { get; set; }
public ಠ_ಠAttribute()
{
Log.Info("This code is bad and you should feel bad");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework Condition="$(Configuration)=='Test'">netcoreapp3.0</TargetFramework>
<TargetFramework Condition="$(Configuration)!='Test'">netstandard2.0</TargetFramework>
<IsPackable Condition="$(Configuration)=='Test'">false</IsPackable>
<DefineConstants Condition="$(Configuration)=='Test'">TESTS</DefineConstants>
</PropertyGroup>
@wallymathieu
wallymathieu / personnummer.rb
Created September 18, 2019 08:28 — forked from henrik/personnummer.rb
Generate valid Swedish personnummer.
# Generator for valid Swedish personnummer: http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
# By Henrik Nyh <http://henrik.nyh.se> 2009-01-29 under the MIT license.
require 'date'
module Personnummer
def self.generate(date=nil, serial=nil)
date ||= Date.new(1900+rand(100), 1+rand(12), 1+rand(28))
serial = serial ? serial.to_s : format("%03d", 1+rand(999)) # 001-999
@wallymathieu
wallymathieu / Controllers__ValuesController.fs
Last active July 26, 2019 16:21
1_ClientCredentials.fs
namespace identity.Controllers
open System
open System.Collections.Generic
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore.Mvc
[<Route("api/[controller]")>]
[<ApiController>]
@wallymathieu
wallymathieu / Collection.fs
Created September 5, 2018 17:20
Maxima and minima
open FSharpPlus
open FSharpPlus.Operators
module Collection=
let inline maximaBy (projection: 'T->'Key) (source: '``Collection<'T>``) : '``Collection<'T>``=
let sorted = sortByDescending projection source
match tryHead sorted with
| None -> sorted
| Some max -> takeWhile ((compare <| projection max) >> (=) 0 << projection) sorted