Skip to content

Instantly share code, notes, and snippets.

@kylecorbelli
Last active May 1, 2018 14:33
Show Gist options
  • Select an option

  • Save kylecorbelli/be7967767c19c8af052d7b97797c7b32 to your computer and use it in GitHub Desktop.

Select an option

Save kylecorbelli/be7967767c19c8af052d7b97797c7b32 to your computer and use it in GitHub Desktop.

Revisions

  1. kylecorbelli revised this gist May 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion safe-head-example-reworked.ts
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@ const upperCaseHead: UpperCaseHead = compose(
    ) as UpperCaseHead

    console.log(upperCaseHead([])) // { type: Maybe.Nothing } ie. Nothing
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just 'Rick'
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'RICK' } ie. Just 'RICK'
  2. kylecorbelli revised this gist Apr 30, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion safe-head-example-reworked.ts
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@ const upperCaseHead: UpperCaseHead = compose(
    ) as UpperCaseHead

    console.log(upperCaseHead([])) // { type: Maybe.Nothing } ie. Nothing
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just 'Rick'>
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just 'Rick'
  3. kylecorbelli revised this gist Apr 30, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion safe-head-example-reworked.ts
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,4 @@ const upperCaseHead: UpperCaseHead = compose(
    ) as UpperCaseHead

    console.log(upperCaseHead([])) // { type: Maybe.Nothing } ie. Nothing
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just<string>
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just 'Rick'>
  4. kylecorbelli created this gist Apr 30, 2018.
    8 changes: 8 additions & 0 deletions safe-head-example-reworked.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    type UpperCaseHead = (list: ReadonlyArray<string>) => Maybe<string>
    const upperCaseHead: UpperCaseHead = compose(
    Maybe.map(toUpper),
    safeHead,
    ) as UpperCaseHead

    console.log(upperCaseHead([])) // { type: Maybe.Nothing } ie. Nothing
    console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'rick' } ie. Just<string>