diff --git a/CHANGELOG.md b/CHANGELOG.md index ba9cfb8..7f77ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# Unreleased +* Add all missing type annotations (Filip Hoffmann) + # v1.0.1 (21/12/2025) * Update README.md (Filip Hoffmann) * Update grom.version/0 (Filip Hoffmann) diff --git a/flake.lock b/flake.lock index 62a32e6..b69ce9b 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1765001337, - "narHash": "sha256-6Pex/7RZ84UPdsdPfAL38W/r8Oe8zPVV1GkborQxWnU=", + "lastModified": 1766297333, + "narHash": "sha256-WZ3W65CieAGdQrpbF44svpmhb60pDmurY8PM+3aelaY=", "owner": "Comamoca", "repo": "gleam-overlay", - "rev": "2486a97a5f5d93685d9dfade21ec3dc545ad4fa7", + "rev": "1e34374044150257a16f207aa9ec451172ab5415", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1754725699, - "narHash": "sha256-iAcj9T/Y+3DBy2J0N+yF9XQQQ8IEb5swLFzs23CdP88=", + "lastModified": 1765186076, + "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "85dbfc7aaf52ecb755f87e577ddbe6dbbdbc1054", + "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { @@ -36,11 +36,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1764950072, - "narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=", + "lastModified": 1766070988, + "narHash": "sha256-G/WVghka6c4bAzMhTwT2vjLccg/awmHkdKSd2JrycLc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f61125a668a320878494449750330ca58b78c557", + "rev": "c6245e83d836d0433170a16eb185cefe0572f8b8", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 49f4b8c..0cc5451 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ devShells = forAllSystems (pkgs: { default = pkgs.mkShellNoCC { buildInputs = with pkgs; [ - pkgs.gleam.bin.latest + pkgs.gleam.bin.nightly rebar3 beamPackages.erlang ]; diff --git a/src/grom.gleam b/src/grom.gleam index bf1363c..545d253 100644 --- a/src/grom.gleam +++ b/src/grom.gleam @@ -26,6 +26,6 @@ pub type Error { // FUNCTIONS ------------------------------------------------------------------- -pub fn version() { +pub fn version() -> String { "v1.0.2" } diff --git a/src/grom/channel.gleam b/src/grom/channel.gleam index 59c1af8..a4b9840 100644 --- a/src/grom/channel.gleam +++ b/src/grom/channel.gleam @@ -480,7 +480,7 @@ pub fn text_decoder() -> decode.Decoder(Channel) { } @internal -pub fn dm_decoder() { +pub fn dm_decoder() -> decode.Decoder(Channel) { use id <- decode.field("id", decode.string) use last_message_id <- decode.field( "last_message_id", diff --git a/src/grom/command.gleam b/src/grom/command.gleam index 892f819..33ce2f1 100644 --- a/src/grom/command.gleam +++ b/src/grom/command.gleam @@ -2317,11 +2317,15 @@ pub fn new_create_global_slash_command( ) } -pub fn new_create_global_user_command(named name: String) { +pub fn new_create_global_user_command( + named name: String, +) -> CreateGlobalUserCommand { CreateGlobalUserCommand(name, None, None, None, None, False) } -pub fn new_create_global_message_command(named name: String) { +pub fn new_create_global_message_command( + named name: String, +) -> CreateGlobalMessageCommand { CreateGlobalMessageCommand(name, None, None, None, None, False) } diff --git a/src/grom/component/section.gleam b/src/grom/component/section.gleam index 4260d9d..7bfd96e 100644 --- a/src/grom/component/section.gleam +++ b/src/grom/component/section.gleam @@ -53,7 +53,7 @@ pub fn component_decoder() -> decode.Decoder(Component) { } @internal -pub fn accessory_decoder() { +pub fn accessory_decoder() -> decode.Decoder(Accessory) { use type_ <- decode.field("type", decode.int) case type_ { 2 -> { diff --git a/src/grom/component/user_select.gleam b/src/grom/component/user_select.gleam index 388ac45..d8a095c 100644 --- a/src/grom/component/user_select.gleam +++ b/src/grom/component/user_select.gleam @@ -111,7 +111,7 @@ pub fn to_json(user_select: UserSelect) -> Json { } @internal -pub fn default_value_to_json(default_value: DefaultValue) { +pub fn default_value_to_json(default_value: DefaultValue) -> Json { json.object([ #("id", json.string(default_value.id)), #("type", json.string("user")), diff --git a/src/grom/gateway.gleam b/src/grom/gateway.gleam index 469efab..9218065 100644 --- a/src/grom/gateway.gleam +++ b/src/grom/gateway.gleam @@ -2385,7 +2385,10 @@ fn try_resume(connection_state: Connection(user_state)) -> Nil { } } -fn resume(connection_state: Connection(user_state), resuming_info: ResumingInfo) { +fn resume( + connection_state: Connection(user_state), + resuming_info: ResumingInfo, +) -> Nil { let request_url = resuming_info.resume_gateway_url |> string.replace(each: "wss://", with: "https://") @@ -2500,6 +2503,9 @@ fn reconnect(connection_state: Connection(user_state)) -> Nil { fn on_connection_manager_message( current: Option(Subject(stratus.InternalMessage(UserMessage(user_state)))), message: ConnectionManagerMessage(user_state), +) -> actor.Next( + Option(Subject(stratus.InternalMessage(UserMessage(user_state)))), + a, ) { case current { Some(manager) -> { @@ -2551,7 +2557,7 @@ pub fn identify_with_presence( pub fn update_presence( connection_state: Connection(user_state), using message: UpdatePresenceMessage, -) { +) -> Nil { process.send( connection_state.manager, SendUserMessage(StartPresenceUpdate(message)), @@ -2561,7 +2567,7 @@ pub fn update_presence( pub fn update_voice_state( connection_state: Connection(user_state), using message: UpdateVoiceStateMessage, -) { +) -> Nil { process.send( connection_state.manager, SendUserMessage(StartVoiceStateUpdate(message)), @@ -2571,7 +2577,7 @@ pub fn update_voice_state( pub fn request_guild_members( connection_state: Connection(user_state), using message: RequestGuildMembersMessage, -) { +) -> Nil { process.send( connection_state.manager, SendUserMessage(StartGuildMembersRequest(message)), @@ -2581,7 +2587,7 @@ pub fn request_guild_members( pub fn request_soundboard_sounds( connection_state: Connection(user_state), for guild_ids: List(String), -) { +) -> Nil { process.send( connection_state.manager, SendUserMessage(StartSoundboardSoundsRequest(guild_ids)), @@ -2659,7 +2665,7 @@ fn on_start_guild_members_request( connection_state: Connection(user_state), connection: stratus.Connection, msg: RequestGuildMembersMessage, -) { +) -> stratus.Next(Connection(user_state), a) { let send_result = msg |> request_guild_members_message_to_json @@ -2677,7 +2683,7 @@ fn on_start_voice_state_update( connection_state: Connection(user_state), connection: stratus.Connection, msg: UpdateVoiceStateMessage, -) { +) -> stratus.Next(Connection(user_state), a) { let send_result = msg |> update_voice_state_message_to_json @@ -2787,7 +2793,10 @@ fn on_reconnect_request( stratus.stop() } -fn send_error(err: grom.Error, connection_state: Connection(user_state)) { +fn send_error( + err: grom.Error, + connection_state: Connection(user_state), +) -> stratus.Next(Connection(user_state), a) { let next = connection_state.event_handler( connection_state.user_state, @@ -3125,7 +3134,7 @@ type HeartbeatCount { fn start_heartbeats( every interval: Duration, send_to connection_manager: Subject(ConnectionManagerMessage(user_state)), -) { +) -> Result(actor.Started(Subject(HeartbeatManagerMessage)), grom.Error) { let initial_wait = interval |> duration.to_seconds @@ -3165,7 +3174,7 @@ fn start_heartbeats( fn on_heartbeat_manager_message( current: HeartbeatState(user_state), message: HeartbeatManagerMessage, -) { +) -> actor.Next(HeartbeatState(user_state), a) { case message { HeartbeatSent -> actor.continue( @@ -3236,4 +3245,4 @@ fn check_heartbeat_equality( } // sounds better -const heartbeat_jitter = float.random +const heartbeat_jitter: fn() -> Float = float.random diff --git a/src/grom/guild/integration.gleam b/src/grom/guild/integration.gleam index feb3beb..542c8b6 100644 --- a/src/grom/guild/integration.gleam +++ b/src/grom/guild/integration.gleam @@ -171,7 +171,7 @@ pub fn application_decoder() -> decode.Decoder(Application) { } @internal -pub fn expire_behavior_decoder() { +pub fn expire_behavior_decoder() -> decode.Decoder(ExpireBehavior) { use variant <- decode.then(decode.int) case variant { 0 -> decode.success(RemoveRole) diff --git a/src/grom/guild_member.gleam b/src/grom/guild_member.gleam index fe207a3..8121ffb 100644 --- a/src/grom/guild_member.gleam +++ b/src/grom/guild_member.gleam @@ -62,7 +62,7 @@ pub type Modify { // FLAGS ----------------------------------------------------------------------- @internal -pub fn bits_member_flags() { +pub fn bits_member_flags() -> List(#(Int, Flag)) { [ #(int.bitwise_shift_left(1, 0), DidRejoin), #(int.bitwise_shift_left(1, 1), CompletedOnboarding), diff --git a/src/grom/interaction.gleam b/src/grom/interaction.gleam index 3a8c84d..926e9b1 100644 --- a/src/grom/interaction.gleam +++ b/src/grom/interaction.gleam @@ -1297,7 +1297,7 @@ pub fn response_message_to_json(message: ResponseMessage) -> Json { } @internal -pub fn modal_response_to_json(modal: ModalResponse) { +pub fn modal_response_to_json(modal: ModalResponse) -> Json { json.object([ #("custom_id", json.string(modal.custom_id)), #("title", json.string(modal.title)), @@ -1306,7 +1306,7 @@ pub fn modal_response_to_json(modal: ModalResponse) { } @internal -pub fn modify_original_response_to_json(modify: ModifyOriginalResponse) { +pub fn modify_original_response_to_json(modify: ModifyOriginalResponse) -> Json { [ modification.to_json(modify.content, "content", json.string), modification.to_json(modify.embeds, "embeds", json.array(_, embed.to_json)), diff --git a/src/grom/internal/rest.gleam b/src/grom/internal/rest.gleam index 744622d..b4e795a 100644 --- a/src/grom/internal/rest.gleam +++ b/src/grom/internal/rest.gleam @@ -16,9 +16,9 @@ import status_code // CONSTANTS ------------------------------------------------------------------- -const discord_url = "discord.com" +const discord_url: String = "discord.com" -const discord_api_path = "api/v10" +const discord_api_path: String = "api/v10" // INTERNAL FUNCTIONS ----------------------------------------------------------