# E4059

Cannot define public methods for builtin types or types that come from other
packages.

MoonBit only allows defining public methods for types that are defined in the
current package.

## Erroneous example

In package `a`:

```{literalinclude} /sources/error_codes/4059_error/a/top.mbt
:language: moonbit
```

In package `b`:

```{literalinclude} /sources/error_codes/4059_error/top.mbt
:language: moonbit
```

Defining public methods for builtin types, or types in the standard library, is
another frequent case of this error:

```{literalinclude} /sources/error_codes/4059_error/top_1.mbt
:language: moonbit
```

## Suggestion

You can either move the type definition to the current package:

```{literalinclude} /sources/error_codes/4059_fixed/top.mbt
:language: moonbit
```

Or use a wrapper type around the builtin type or type from another package:

```{literalinclude} /sources/error_codes/4059_fixed/top_1.mbt
:language: moonbit
```
