|
1 | | -import gleam/dynamic.{type DecodeErrors, type Dynamic} |
| 1 | +import gleam/dynamic.{type Dynamic} |
| 2 | +import gleam/dynamic/decode.{type DecodeError} |
2 | 3 | import gleam/erlang.{type Reference} |
3 | 4 | import gleam/erlang/atom.{type Atom} |
4 | 5 | import gleam/string |
@@ -238,7 +239,7 @@ pub fn selecting_trapped_exits( |
238 | 239 | let reason = message.2 |
239 | 240 | let normal = dynamic.from(Normal) |
240 | 241 | let killed = dynamic.from(Killed) |
241 | | - let reason = case dynamic.string(reason) { |
| 242 | + let reason = case decode.run(reason, decode.string) { |
242 | 243 | _ if reason == normal -> Normal |
243 | 244 | _ if reason == killed -> Killed |
244 | 245 | Ok(reason) -> Abnormal(reason) |
@@ -743,7 +744,7 @@ pub type Cancelled { |
743 | 744 | /// Cancel a given timer, causing it not to trigger if it has not done already. |
744 | 745 | /// |
745 | 746 | pub fn cancel_timer(timer: Timer) -> Cancelled { |
746 | | - case dynamic.int(erlang_cancel_timer(timer)) { |
| 747 | + case decode.run(erlang_cancel_timer(timer), decode.int) { |
747 | 748 | Ok(i) -> Cancelled(i) |
748 | 749 | Error(_) -> TimerNotFound |
749 | 750 | } |
@@ -847,13 +848,13 @@ pub fn named(name: Atom) -> Result(Pid, Nil) |
847 | 848 | /// |
848 | 849 | /// ```gleam |
849 | 850 | /// import gleam/dynamic |
850 | | -/// from_dynamic(dynamic.from(process.self())) |
| 851 | +/// pid_from_dynamic(dynamic.from(process.self())) |
851 | 852 | /// // -> Ok(process.self()) |
852 | 853 | /// ``` |
853 | 854 | /// |
854 | 855 | /// ```gleam |
855 | | -/// from_dynamic(dynamic.from(123)) |
| 856 | +/// pid_from_dynamic(dynamic.from(123)) |
856 | 857 | /// // -> Error([DecodeError(expected: "Pid", found: "Int", path: [])]) |
857 | 858 | /// ``` |
858 | 859 | @external(erlang, "gleam_erlang_ffi", "pid_from_dynamic") |
859 | | -pub fn pid_from_dynamic(from from: Dynamic) -> Result(Pid, DecodeErrors) |
| 860 | +pub fn pid_from_dynamic(from from: Dynamic) -> Result(Pid, List(DecodeError)) |
0 commit comments