From ac39e70962596d601b2e823d434105f447ed97ba Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 28 Sep 2026 16:31:23 +0000 Subject: [PATCH] Annotate to_inspect so it stays an inspect override on newer nightlies Since nightly-2026-09-23, to_inspect overrides inspection only when its type is T -> Str. Unannotated, a to_inspect that returns a string literal infers a polymorphic result (the literal could be any type with from_interpolation), so it is silently ignored. Co-Authored-By: Claude Opus 5.5 (1M context) --- examples/CustomInspect/OpaqueTypes.roc | 1 + examples/EncodeDecode/main.roc | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/CustomInspect/OpaqueTypes.roc b/examples/CustomInspect/OpaqueTypes.roc index 624f4d1..2566845 100644 --- a/examples/CustomInspect/OpaqueTypes.roc +++ b/examples/CustomInspect/OpaqueTypes.roc @@ -30,6 +30,7 @@ main! = |_| { ### start snippet secret CreditCard :: Str.{ create = |nb| CreditCard.(nb) + to_inspect : CreditCard -> Str to_inspect = |CreditCard.(nb)| { last_four_digits = nb.to_utf8().take_last(4) |> Str.from_utf8 ?? "****" # Note: do not use this default in production. If your credit card string cannot be converted to utf8 you should fail loudly. "**** **** **** ${last_four_digits}" diff --git a/examples/EncodeDecode/main.roc b/examples/EncodeDecode/main.roc index 0b4eca2..8915415 100644 --- a/examples/EncodeDecode/main.roc +++ b/examples/EncodeDecode/main.roc @@ -14,6 +14,7 @@ ItemKind := [ ].{ is_eq : _ # enable the default is_eq implementation + to_inspect : ItemKind -> Str to_inspect = |ItemKind.(item_kind)| "ItemKind.(${Str.inspect(item_kind)})" encoder_for : encoding -> (ItemKind, state -> Try(state, []))