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
import * as E from 'fp-ts/Either'; | |
// 1. | |
const MY_VAR_UNSAFE: string | undefined = process.env['MY_VAR']; | |
const MY_VAR_NOT_DEFINED = 'Environment variable MY_VAR not set.' as const; | |
const MY_VAR_EITHER: E.Either<typeof MY_VAR_NOT_DEFINED, string> = | |
MY_VAR_UNSAFE !== undefined |
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 person = Streamer(string) | Mr(string) | |
let kirJs = Streamer("KirJS") | |
let mrLapteuh = Mr("Lapteuh") | |
let say = person => | |
switch person { | |
| Streamer(name) => name ++ ": " ++ "Yes, mr. Lapteuh." ++ "\n" | |
| Mr(name) => "Mr. " ++ name ++ ": " ++ "Say my name!" ++ "\n" |
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
interface InternalEventBrand { | |
readonly Internal: unique symbol; | |
} | |
type User = {} | |
type AuthorizedEvent = { type: 'AUTHORIZED'; user: User } & InternalEventBrand; | |
function authorized(user: User): AuthorizedEvent { | |
return { type: 'AUTHORIZED', user } as AuthorizedEvent; |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |