Skip to content

Instantly share code, notes, and snippets.

Avatar

Oskar Gewalli wallymathieu

View GitHub Profile
@wallymathieu
wallymathieu / onion-1.fs
Last active Sep 20, 2022 — forked from akhansari/onion-1.fs
F# : Onion architecture in a nutshell
View onion-1.fs
// 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 Dec 27, 2021
Typeprovider issue
View Program.fs
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 Jun 13, 2020
Coverage report 2020-06-13 F#+
View coverage.cobertura.xml
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 Jun 13, 2020
Coverage report 2020-06-13 F#+
View coverage.cobertura.xml
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
Problem with microsoft.dotnet-interactive/1.0.115407 dotnet 5.0.100-preview.4.20258.7
View Trying-out-fleece.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View gist:1258d92e13731f4fb14e65daa734dde7
[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");
}
}
View LibWithTests.csproj
<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 Sep 18, 2019 — forked from henrik/personnummer.rb
Generate valid Swedish personnummer.
View personnummer.rb
# 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
View Controllers__ValuesController.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>]
View Collection.fs
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