-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Milestone
Description
Suppose you have a C struct e.g. (Pattern.MatchResult)
and a function returning (Array Pattern.MatchResult) e.g. (Pattern.find-all-matches).
then printing in the REPL does not work, since
carp: Can't find any 'prn' function for member 'Inside array.'
Note that printing the struct itself works however e.g. with (Pattern.match
so the str interface can find the correct implementation for the struct (not an Array of the struct).
> (info prn)
prn : (Fn [a] String) = {
StaticArray.str
Function.Arity0.prn
; ... several lines omitted
Pointer.prn
Pattern.MatchResult.refmatch2str
Pattern.MatchResult.match2str
Pattern.prn
Unit.prn
}
> (info Pattern.MatchResult.match2str)
Pattern.MatchResult.match2str : (Fn [Pattern.MatchResult] String)
Defined at line 14, column 6 in '/home/ptokremin/contrib_ghub/Carp/core/Pattern.carp'
Implements: (prn str)
> (info Pattern.MatchResult.refmatch2str)
Pattern.MatchResult.refmatch2str : (Fn [(Ref Pattern.MatchResult a)] String)
Defined at line 7, column 6 in '/home/ptokremin/contrib_ghub/Carp/core/Pattern.carp'
Implements: (prn str)
> (Pattern.match #"<(.-)>{(.-)}" "Whatever we <do>{cmd1} is going to cause some <trouble>{msg2} no matter...")
(MatchResult start=12 end=22)
> (Pattern.find-all-matches #"<(.-)>{(.-)}" "Whatever we <do>{cmd1} is going to cause some <trouble>{msg2} no matter...")
[Warning] No 'prn' function found with type (Fn [Pattern.MatchResult] String).
carp: Can't find any 'prn' function for member 'Inside array.' of type (Fn [Pattern.MatchResult] String)
CallStack (from HasCallStack):
error, called at src/ArrayTemplates.hs:634:33 in CarpHask-0.5.1.0-EudeCbDnX8j3pnSP31uN8I:ArrayTemplates
The example stems from PR #1257.