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
<?xml version="1.0" encoding="UTF-8"?> | |
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"> | |
<gesmes:subject>Reference rates</gesmes:subject> | |
<gesmes:Sender> | |
<gesmes:name>European Central Bank</gesmes:name> | |
</gesmes:Sender> | |
<Cube> | |
<Cube time='2023-05-25'> | |
<Cube currency='USD' rate='1.0735'/> |
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
// from this tweet https://twitter.com/mattpocockuk/status/1622730173446557697 | |
type Prettify<T> = { | |
[K in keyof T]: T[K] | |
} & {}; |
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
{ "date": "11-07-22", "rates": { "USD": "1.0163", "JPY": "138.05", "BGN": "1.9558", "CZK": "24.614", "DKK": "7.4424", "GBP": "0.84585", "HUF": "402.45", "PLN": "4.7630", "RON": "4.9431", "SEK": "10.6665", "CHF": "0.9913", "ISK": "139.50", "NOK": "10.2630", "HRK": "7.5190", "TRY": "17.6026", "AUD": "1.4871", "BRL": "5.4345", "CAD": "1.3201", "CNY": "6.8095", "HKD": "7.9769", "IDR": "15210.73", "ILS": "3.5325", "INR": "80.5280", "KRW": "1321.61", "MXN": "20.8477", "MYR": "4.4992", "NZD": "1.6464", "PHP": "56.882", "SGD": "1.4228", "THB": "36.602", "ZAR": "17.1922" }} |
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
export const compose = <Name extends string, I2, A extends I2, B, I1, O1>( | |
name: Name, | |
Codec1: t.Type<A, O1, I1>, | |
Codec2: t.Type<B, A, I2> | |
): t.Type<B, O1, I1> => { | |
return new t.Type<B, O1, I1>( | |
name, | |
(u): u is B => Codec2.is(u), | |
(a, c) => | |
pipe( |
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 chartag = Symbol("char"); | |
export type Char = string & { __tag: typeof chartag }; | |
type IsChar<S extends string> = S extends `${infer Head}${infer Tail}` | |
? Head extends "" | |
? never | |
: Tail extends "" | |
? Char | |
: never |
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 Zero = []; | |
type Nat = [Nat] | Zero; | |
type NonZeroNat = [NonZeroNat] | [Zero]; | |
type Inc<A extends Nat> = [A]; | |
type Dec<A extends NonZeroNat> = A[0]; | |
type Add<A extends Nat, B extends Nat> = Add_<A, B>; | |
// This trick taken from https://github.com/Microsoft/TypeScript/pull/24897 | |
type Add_<A extends Nat, B extends Nat> = { |
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 getLongestSemigroup = < | |
A extends { length: number } = never | |
>(): S.Semigroup<A> => { | |
return { concat: (x, y) => (x.length > y.length ? x : y) }; | |
}; | |
const getLongestOptionSemigroup = O.getMonoid<Unit>(getLongestSemigroup()); | |
const longestString = getLongestOptionSemigroup.concat( | |
string1Opt, |
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
// Maybe | |
class Nothing { | |
readonly tag: "None" = "None"; | |
public map = (): Nothing => new Nothing(); | |
} | |
class Just<A> { | |
readonly tag: "Just" = "Just"; | |
constructor(readonly value: A) {} | |
public map = <B>(fn: (a: A) => B): Just<B> => new Just(fn(this.value)); |
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
// Maybe | |
class Nothing { | |
readonly tag: "None" = "None"; | |
} | |
class Just<A> { | |
readonly tag: "Just" = "Just"; | |
constructor(readonly value: A) {} | |
} |
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
{-- | |
By considering the terms in the Fibonacci sequence whose values do not exceed four million, | |
find the sum of the even-valued terms. | |
--} | |
let fib = 1 : 2 : zipWith (+) fib (tail fib) | |
foldr (+) 0 $ filter even $ takeWhile (< 4e6) fib |
NewerOlder