<commit_before># How `HKT`, `URI2HKT`, `URIS` and `Type` work

## Introduction

Here's the definition of `HKT`

```ts
// HKT.ts

export interface HKT<URI, A> {
  readonly _URI: URI
  readonly _A: A
}
```

and `Functor`

```ts
// Functor.ts
import { HKT } from 'fp-ts/lib/HKT'

export interface Functor<F> {
  readonly URI: F
  map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>
}

export function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {
  return f => fa => F.map(fa, f)
}
```

We can define an instance of `Functor` for `Identity`

```ts
// Identity.ts
import { Functor } from 'fp-ts/lib/Functor'

export const URI = 'Identity'

export type URI = typeof URI

export class Identity<A> {
  readonly _A: A // --> these phantom fields make `Identity` an `HKT`, note that both `A` and `URI` here are types
  readonly _URI: URI // ----^
  constructor(readonly value: A) {}
  map<B>(f: (a: A) => B): Identity<B> {
    return new Identity(f(this.value))
  }
}<commit_msg>Docs: add definite assignment assertions<commit_after># How `HKT`, `URI2HKT`, `URIS` and `Type` work

## Introduction

Here's the definition of `HKT`

```ts
// HKT.ts

export interface HKT<URI, A> {
  readonly _URI: URI
  readonly _A: A
}
```

and `Functor`

```ts
// Functor.ts
import { HKT } from 'fp-ts/lib/HKT'

export interface Functor<F> {
  readonly URI: F
  map: <A, B>(fa: HKT<F, A>, f: (a: A) => B) => HKT<F, B>
}

export function lift<F>(F: Functor<F>): <A, B>(f: (a: A) => B) => (fa: HKT<F, A>) => HKT<F, B> {
  return f => fa => F.map(fa, f)
}
```

We can define an instance of `Functor` for `Identity`

```ts
// Identity.ts
import { Functor } from 'fp-ts/lib/Functor'

export const URI = 'Identity'

export type URI = typeof URI

export class Identity<A> {
  readonly _A!: A // --> these phantom fields make `Identity` an `HKT`, note that both `A` and `URI` here are types
  readonly _URI!: URI // ----^
  constructor(readonly value: A) {}
  map<B>(f: (a: A) => B): Identity<B> {
    return new Identity(f(this.value))
  }
}
{'fraction_non_alphanumeric': 0.19198827552515876, 'fraction_numerical': 0.0009770395701025891, 'mean_word_length': 3.4425162689804774, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7604371', 'n_tokens_mistral': 859, 'n_tokens_neox': 811, 'n_words': 264}