> For the complete documentation index, see [llms.txt](https://funkcia.lukemorales.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://funkcia.lukemorales.io/modules/predicate.md).

# Predicate

The Predicate module provides utilities for type-safe predicate functions in TypeScript.

#### not

Returns a new function that will return the opposite boolean value of the original predicate.

```typescript
import { not } from 'funkcia';

const isGreaterThanZero = (value: number): boolean => value > 0;
const isLessOrEqualToZero = not(isGreaterThanZero);

const result = isLessOrEqualToZero(-1);
        //^?  true
```

#### Predicate\<A>

Represents a function that tests a value and returns a boolean.

```typescript
import { Predicate } from 'funkcia/predicate';

const isPositive: Predicate.Predicate<number> = (n) => n > 0;
```

#### Guard\<A, B extends A>

Represents a type guard function that refines a type `A` to a more specific type `B`.

```typescript
import { Predicate } from 'funkcia/predicate';

const isString: Predicate.Guard<unknown, string> = (value) =>
  typeof value === 'string';
```

#### Guarded\<Guard>

Utility type that extracts the refined type `B` from a `Guard<A, B>`.

```typescript
import { Predicate } from 'funkcia/predicate';

type StringGuard = Predicate.Guard<unknown, string>;
type Refined = Predicate.Guarded<StringGuard>;
//      ^? string
```

#### Unguarded\<A, B extends A>

Utility type that computes the type that was excluded by the type guard refinement.

```typescript
import { Predicate } from 'funkcia/predicate';

type Shape = Circle | Square | Triangle;
type UnguardedShape = Predicate.Unguarded<Shape, Circle>;
//        ^? Square | Triangle
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://funkcia.lukemorales.io/modules/predicate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
