Confusion Regarding Recent @deprecated M0235 Annotations in Core Library (Map & Result)

Hello,
I would like to share some confusion I have encountered while working with the recent core library updates, particularly around a number of newly introduced @deprecated M0235 annotations. I may be missing some context, so I am outlining my current understanding and uncertainties below.

1. Deprecation warnings during development

Recently, the compiler began reporting that the replace method in the core Map module, as well as parts of the Result module, are deprecated. Without any obvious accompanying explanation, this has made it difficult for me to understand how these APIs are expected to be used going forward.

2. Multiple Map mutation APIs marked as deprecated

While reviewing the source code, I noticed that Map.replace is not the only affected API. Other methods with similar purposes, such as Map.insert and Map.swap, are also annotated with @deprecated M0235.

From my current perspective, this seems to leave Map.add as the only non-deprecated mutation method. I am unsure whether this interpretation is correct. It also made me wonder what the original motivation was for providing multiple mutation APIs with overlapping behavior, and what considerations led to the decision to deprecate most of them now.

3. Deprecation of Map.toPure and Map.fromPure

I noticed that both Map.toPure and Map.fromPure are marked as deprecated.

In addition, similar to what is seen in the Result module, the type declarations in pure/Map, and in several other pure/ modules, are also annotated with @deprecated M0235. From my perspective, it is unclear whether this combination of deprecations is meant to discourage conversion between Map and pure/Map, or whether it indicates that all pure/ modules are planned to be deprecated.

4. Deprecation of type Result in the Result module

In the Result module, the type Result declaration itself is marked as deprecated.

Seeing that similar @deprecated M0235 annotations appear on type declarations in pure/Map and other pure/ modules, I am unsure whether these annotations are intended to discourage direct use of specific type aliases, or whether they indicate a wider plan to phase out entire modules rather than individual APIs.

5. Missing context around the December 10 update

It appears that the core library update on December 10 introduced a large number of @deprecated M0235 annotations. However, so far I have not been able to find related commits description, changelog entries, official documentation, or public discussions that explain the intent behind this change.

Because of this, I am finding it difficult to understand the broader direction these deprecations are pointing toward, or how developers are expected to adapt.

If the Result module, as well as other modules where the type declarations are marked with @deprecated M0235, such as Region, are intended to be fully deprecated and eventually removed, what are the recommended replacements for these modules?


I wanted to share these observations in case others have run into similar uncertainty, or in case there is existing context that I may have overlooked.
Thank you.

Thank you for your message!

sorry for the confusion, this is a caffeine-related deprecation (see the motoko changelog), where these projects won’t use the methods annotated with the M0235 code.

This deprecation does not affect regular users.

1 Like

So we should just deal with it basically?
Quite concerned that regular users of Motoko are being put aside. In just one major version of core we got breaking changes and depreciation warnings that don’t concern us on some of the most used types/modules.

Quite concerned that regular users of Motoko are being put aside.

I can assure you that the Motoko Team is not putting its human users aside. We’ve been strong advocates whereever we can, and have fought tooth and nail for the new context-dot and implicits features to be backwards compatible for our existing users.

In just one major version of core we got breaking changes and depreciation warnings that don’t concern us on some of the most used types/modules.

The M0235 warning will not be produced unless you set a particular compiler flag, so you will not suddenly get a bunch of deprecation warnings. These will show up in the completion popups right now, but I’ve added an issue to hide them in the future.

I’m not sure which breaking changes exactly you’re referring to, but the ones mentioned in the Changelog are definitely beneficial to our regular users of Motoko:

  • Breaking: Text.join, Float.format parameter order swap. ← Makes it so you can write ["Hello", "World"].join(" ") and (1.234).format(#exact)
  • Breaking: Rename sort to sortInPlace, add sort (#405). ← Improves API consistency between the different collection types
2 Likes