From b967a5e9f413c17e658a54762f99dcdf6cecb46b Mon Sep 17 00:00:00 2001 From: gcanti Date: Wed, 18 Dec 2019 06:45:03 +0100 Subject: [PATCH] fix inconsistent naming, closes #399 --- README.md | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d63386a6..e72d24eb 100644 --- a/README.md +++ b/README.md @@ -127,16 +127,10 @@ const onLeft = (errors: t.Errors): string => `${errors.length} error(s) found` // success handler const onRight = (s: string) => `No errors: ${s}` -pipe( - t.string.decode('a string'), - fold(onLeft, onRight) -) +pipe(t.string.decode('a string'), fold(onLeft, onRight)) // => "No errors: a string" -pipe( - t.string.decode(null), - fold(onLeft, onRight) -) +pipe(t.string.decode(null), fold(onLeft, onRight)) // => "1 error(s) found" ``` @@ -254,7 +248,10 @@ import { fold } from 'fp-ts/lib/Either' const getPaths = (v: t.Validation): Array => { return pipe( v, - fold(errors => errors.map(error => error.context.map(({ key }) => key).join('.')), () => ['no errors']) + fold( + errors => errors.map(error => error.context.map(({ key }) => key).join('.')), + () => ['no errors'] + ) ) } @@ -350,14 +347,14 @@ interface Bar { } const Foo: t.Type = t.recursion('Foo', () => - t.interface({ + t.type({ type: t.literal('Foo'), b: t.union([Bar, t.undefined]) }) ) const Bar: t.Type = t.recursion('Bar', () => - t.interface({ + t.type({ type: t.literal('Bar'), a: t.union([Foo, t.undefined]) }) @@ -490,6 +487,7 @@ interface ResponseBody { result: T _links: Links } + interface Links { previous: string next: string @@ -499,14 +497,14 @@ interface Links { Would be: ```ts -// t.Mixed = t.Type -const ResponseBody = (codec: C) => - t.interface({ +// where `t.Mixed = t.Type` +const responseBody = (codec: C) => + t.type({ result: codec, _links: Links }) -const Links = t.interface({ +const Links = t.type({ previous: t.string, next: t.string }) @@ -519,7 +517,7 @@ const UserModel = t.type({ name: t.string }) -functionThatRequiresRuntimeType(ResponseBody(t.array(UserModel)), ...params) +functionThatRequiresRuntimeType(responseBody(t.array(UserModel)), ...params) ``` # Piping @@ -537,10 +535,7 @@ const NumberCodec = new t.Type( String ) -const NumberFromString = t.string.pipe( - NumberCodec, - 'NumberFromString' -) +const NumberFromString = t.string.pipe(NumberCodec, 'NumberFromString') ``` # Community