Skip to content

Instantly share code, notes, and snippets.

View CoditCompany's full-sized avatar
👋
You can find us on @CoditEU

Codit CoditCompany

👋
You can find us on @CoditEU
View GitHub Profile
open FPrimitive
let unknown = 10
let untrusted = Untrust unknown
type NonZeroInt =
private NonZeroInt of int with
static member create x =
Spec.def<int>
|> Spec.notEqual 0 "should not be zero"
int unknown = 5;
var untrusted = Untrust<int>(unknown);
if (untrusted.TryGetValue(x => x > 3, out int trusted))
{
// Set 'trusted' now into dedicated 'Int' type.
}
// Specification that the input parameter of the access-controlled function should satisfy
let spec =
Spec.def<string>
|> Spec.notEmpty "should not be empty string"
// The function (fun x -> Some x) is now 'access-controlled' with a specifiation for non-empty strings,
// can be revoked anytime the 'Access.revoke acc' is called, and can only be accessed three times.
let acc =
Access.func (fun x -> Some x)
|> Access.satisfy spec
// Specification before the actual check of the base-uri.
Spec<Uri> spec =
Spec.Of<Uri>()
.Add(uri => uri.Scheme == Uri.UriSchemeHttps, "should be 'https' scheme");
// Demonstration purposes, generic type could be anything.
IObservable<T> obs = null;
// Access controlled function with validation, revocation, limited amount of evaluations and time-based availability.
Access<Uri, Uri> access =
open FPrimitive
/// Composible specifications for your domain types:
type NonEmptyString =
private NonEmptyString of string with
static member create x =
Spec.def<string>
|> Spec.notNull "should not be null"
|> Spec.notEmpty "should not be empty"
|> Spec.createModel NonEmptyString x
using FPrimitive;
public class ProductName
{
private readonly string _value;
/// Prevents a default instance of the type from being created.
private ProductName(string value)
{
_value = value;
open FScenario
Http.get "http://localhost:9090/"
// Logging:
// Information: GET -> http://localhost:9090
// Information: OK <- http://localhost:9090
open FScenario
// Polling Computation Expression
pol { target (fun () -> async { return FileInfo "C:/temp/file.txt" })
until (fun f -> f.Exists)
every _1s
timeout _5s
error "Polling at file path 'C:/temp/file.txt' doesn't result in any file" }
// Pipable polling functions
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:s0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="/s0:EFACT_D96A_ORDERS_EAN008" />
</xsl:template>
<xsl:template match="/s0:EFACT_D96A_ORDERS_EAN008">
<order>
<reference>
<xsl:value-of select="s0:BGM/BGM02" />
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"accessPolicies": {
"defaultValue": { "list": [] },
"type": "object"
}
},
"variables": {