Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfeldman committed Sep 12, 2023
1 parent 5b8cf76 commit c7fb2ac
Show file tree
Hide file tree
Showing 6 changed files with 1,139 additions and 46 deletions.
22 changes: 16 additions & 6 deletions crates/compiler/builtins/roc/Inspect.roc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ interface Inspect
custom,
apply,
toInspector,
# TODO don't expose these - there's some way to do this!
inspectFn,
inspectOpaque,
]
imports [
Bool.{ Bool },
Expand All @@ -57,12 +60,11 @@ InspectFormatter implements
set : set, ElemWalker state set elem, (elem -> Inspector f) -> Inspector f where f implements InspectFormatter
dict : dict, KeyValWalker state dict key value, (key -> Inspector f), (value -> Inspector f) -> Inspector f where f implements InspectFormatter

# Note opaque is used for both opaque types and functions.
# The auto deriver for functions probably could put the function type.
# For regular opaque types, I think we can use the type name, though that may lead to some reflection related issues that still need to be discussed.
# As a simple baseline, it can just use the exact words `opaque` and `function` for now.
# In text, this would render as `<opaque>`, `<function>`, etc
opaque : Str -> Inspector f where f implements InspectFormatter
# In text, this would render as `<opaque>`
opaque : Inspector f where f implements InspectFormatter

# In text, this would render as `<function>`
function : Inspector f where f implements InspectFormatter

u8 : U8 -> Inspector f where f implements InspectFormatter
i8 : I8 -> Inspector f where f implements InspectFormatter
Expand Down Expand Up @@ -94,3 +96,11 @@ inspect : val -> f where val implements Inspect, f implements InspectFormatter
inspect = \val ->
(@Inspector valFn) = toInspector val
valFn (init {})

## Should not be exposed, only used in auto-deriving
inspectFn : * -> Inspector f where f implements InspectFormatter
inspectFn = \_ -> function

## Should not be exposed, only used in auto-deriving
inspectOpaque : * -> Inspector f where f implements InspectFormatter
inspectOpaque = \_ -> opaque
Loading

0 comments on commit c7fb2ac

Please sign in to comment.