Skip to content

Instantly share code, notes, and snippets.

@MichalZalecki
Created April 23, 2019 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichalZalecki/1c86538f56ae7f9e7c3ed31b3bdbfd17 to your computer and use it in GitHub Desktop.
Save MichalZalecki/1c86538f56ae7f9e7c3ed31b3bdbfd17 to your computer and use it in GitHub Desktop.
const isString = (u: unknown): u is string => typeof u === "string";
// Type<A, O, I>
const string = new t.Type<string, string, unknown>(
"string",
isString,
(input, context) => isString(input) ? t.success(input) : t.failure(input, context),
t.identity,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment