View flake.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "A very basic flake"; | |
inputs = { | |
fenix = { | |
url = "github:nix-community/fenix"; | |
inputs.nixpkgs.follows = "nixpkgs"; | |
}; | |
nixpkgs = { | |
url = "nixpkgs/nixos-unstable"; |
View roman.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const conversions = [ | |
[1000, 'M'], | |
[900, 'CM'], | |
[500, 'D'], | |
[400, 'CD'], | |
[100, 'C'], | |
[90, 'XC'], | |
[50, 'L'], | |
[40, 'XL'], | |
[10, 'X'], |
View nonempty.purs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Data.NonEmptyArray where | |
import Prelude | |
data NonEmpty a = | |
NonEmpty a (Array a) | |
instance showNonEmpty :: Show a => Show (NonEmpty a) where | |
show (NonEmpty a as) = "NonEmpty: " <> show a <> show as |
View machinestyling.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Prompted by discussion in the F# Slack, where it was proposed that reducing the use of CEs | |
might help people more easily pick up Freya. | |
Of course, there's no reason why both syntaxes can't be made available if that seems like | |
the right option. | |
The basic freya { ... } CE is a genuine monad, and so would always stay as a CE option (though | |
it can also be expressed using standard combinator operators/named functions already). |
View example.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Address = | |
{ Street: string | |
Number: int } | |
static member ToJson (x: Address) = | |
json { | |
do! Json.write "street" x.Street | |
do! Json.write "streetNumber" x.Number } | |
type House = |
View fileserver.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
open Freya.Core | |
open Freya.Core.Operators | |
open Freya.Machines.Http | |
open Freya.Routers.Uri.Template | |
open Freya.Types.Http | |
// Configuration | |
let fileTypes = |
View morphisms.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let record = | |
{ Ages = "24,56,45,10" } | |
(* 56 *) | |
let oldest = | |
Optic.get recordints_ record |> List.max | |
(* { Ages = "25,57,46,11" } *) | |
let record' = | |
Optic.map recordints_ (List.map ((+) 1)) record |
View html.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Builder | |
type Builder<'a> (operations: BuilderOperations<'a>) = | |
member __.Return _ : 'a = | |
operations.Init () | |
member __.ReturnFrom (c: 'a) : 'a = | |
c |
View monadic.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementations | |
module Reader = | |
let bind (f: 'e -> 't, binder: 't -> 'e -> 'u) : 'e -> 'u = | |
fun e -> | |
binder (f e) e | |
// Specializations |
View gist:bfec885e5ef9465bd13d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let t2 = | |
TopicDescription "testtopic2" | |
let t3 = | |
TopicDescription "testtopic3" | |
let setup = | |
ServiceBus.run ( | |
ServiceBus.liftNamespace ( | |
Namespace.Topics.create t3 |
NewerOlder