Skip to content

Instantly share code, notes, and snippets.

@roger-hamilton
roger-hamilton / SqlParams.ts
Last active August 11, 2021 13:49
Sql Command parameter extraction
type WhiteSpace = ' ' | '\t' | '\n' | '\r' | '\f'
type Trim<S extends string> =
S extends `${WhiteSpace}${infer T}` ? Trim<T>
: S extends `${infer T}${WhiteSpace}` ? Trim<T>
: S
type SqlParamsUnion<T extends string, P extends string = '@'> =
T extends `${any}${P}${infer P}${WhiteSpace}${infer R}`
? Trim<P> | SqlParamsUnion<R>

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x