Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prelude type helpers #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

# v1.0.0 - 02-29-2024
## Unreleased

- The `package_interface` module gains the `list` and `result` functions.
- The `package_interface` module gains the `int`, `float`, `string`, `bool` and
`bit_array` constants.

## v1.0.0 - 02-29-2024

- 🎉 first release
54 changes: 54 additions & 0 deletions src/gleam/package_interface.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,60 @@ import gleam/dynamic.{type DecodeErrors, type Decoder, type Dynamic}
import gleam/option.{type Option}
import gleam/result

// --- GLEAM PRELUDE TYPES -----------------------------------------------------

/// The Gleam `Int` type's representation in a pacakge interface.
///
pub const int = Named(name: "Int", package: "", module: "gleam", parameters: [])

/// The Gleam `Float` type.
///
pub const float = Named(
name: "Float",
package: "",
module: "gleam",
parameters: [],
)

/// The Gleam `String` type's representation in a package interface.
///
pub const string = Named(
name: "String",
package: "",
module: "gleam",
parameters: [],
)

/// The Gleam `Bool` type's representation in a package interface.
///
pub const bool = Named(
name: "Bool",
package: "",
module: "gleam",
parameters: [],
)

/// The Gleam `BitArray` type's representation in a package interface.
///
pub const bit_array = Named(
name: "BitArray",
package: "",
module: "gleam",
parameters: [],
)

/// A Gleam `List` with the given type as its parameter.
///
pub fn list(of type_: Type) -> Type {
Named(name: "List", package: "", module: "gleam", parameters: [type_])
}

/// A Gleam `Result` with the given types as the ok and error parameters.
///
pub fn result(ok: Type, error: Type) -> Type {
Named(name: "Result", package: "", module: "gleam", parameters: [ok, error])
}

// --- TYPES -------------------------------------------------------------------

/// A Gleam package.
Expand Down
Loading