title: What is an fp-ts Predicate?
body: <p>I'm trying to implement some simple data validation with fp-ts, and came across this <a href="https://codesandbox.io/s/array-of-validators-vxgj6?from-embed=&amp;file=/src/arrayOfValidators.ts:0-1648" rel="nofollow noreferrer">codesandboxexample</a>:</p>
  <pre class="lang-ts prettyprint-override"><code>import * as E from &quot;fp-ts/lib/Either&quot;;
  import { getSemigroup, NonEmptyArray } from &quot;fp-ts/lib/NonEmptyArray&quot;;
  import { sequence } from &quot;fp-ts/lib/Array&quot;;
  import { pipe } from &quot;fp-ts/lib/pipeable&quot;;
  import { Predicate } from &quot;fp-ts/lib/function&quot;;
  
  type ValidationError = NonEmptyArray&lt;string&gt;;
  
  type ValidationResult = E.Either&lt;ValidationError, unknown&gt;;
  
  type ValidationsResult&lt;T&gt; = E.Either&lt;ValidationError, T&gt;;
  
  interface Validator {
    (x: unknown): ValidationResult;
  }
  
  interface Name extends String {}
  
  const applicativeV = E.getValidation(getSemigroup&lt;string&gt;());
  
  const validateName: (
    validations: Array&lt;Validator&gt;,
    value: unknown
  ) =&gt; ValidationsResult&lt;Name&gt; = (validations, value) =&gt;
    validations.length
      ? pipe(
          sequence(applicativeV)(validations.map((afb) =&gt; afb(value))),
          E.map(() =&gt; value as Name)
        )
      : E.right(value as Name);
  
  const stringLengthPredicate: Predicate&lt;unknown&gt; = (v) =&gt;
    typeof v === &quot;string&quot; &amp;&amp; v.length &gt; 4;
  
  const lengthAtLeastFour: Validator = E.fromPredicate(
    stringLengthPredicate,
    () =&gt; [&quot;value must be a string of at least 5 characters&quot;]
  );
  
  const requiredLetterPredicate: Predicate&lt;unknown&gt; = (v) =&gt;
    typeof v === &quot;string&quot; &amp;&amp; v.includes(&quot;t&quot;);
  
  const hasLetterT: Validator = E.fromPredicate(requiredLetterPredicate, () =&gt; [
    'value must be a string that includes the letter &quot;t&quot;'
  ]);
  
  const validations = [hasLetterT, lengthAtLeastFour];
  
  console.log(validateName(validations, &quot;sim&quot;));
  // {left: ['value must be a string that includes the letter &quot;t&quot;', 'value must be a string of at least 4 characters']}
  
  console.log(validateName(validations, &quot;timmy&quot;));
  // {right: 'timmy'}
  </code></pre>
  <p>What is <code>Predicate</code>? To what effect is it used in this example? I don't see any explanation of what it does in the docs, just that it's <a href="https://gcanti.github.io/fp-ts/modules/function.ts.html#predicate-interface" rel="nofollow noreferrer">part of the API</a> and that it seems to modify a provided interface.</p>