Closed propensive closed 1 year ago
This may be achievable just by invoking the Contextual macro from another transparent inline
macro, and applying the refinement.
This turns out to be completely possible without any special support from Contextual.
The return type of any Contextual value is fixed, but since the macro is transparent, it could be refined to a subtype. For example, in Guillotine the return type of a shell command such as
sh"cat foo"
could be typed asCommand["cat"]
instead of justCommand
. In this example, it would provide some further opportunities to have type inference automatically choose suitable return types for execution.Known literal
Text
types from Gossamer could be refined to have the underlyingString
literal type available as a member.This would probably be best provided through a mixin trait along the lines of:
A user's implementation of
result
would provide theString
based on the finalState
value which would be passed into theRefined
type constructor to produce a new subtype ofReturn
.An alternative approach may be to change the
Return
type toReturn[S <: String & Singleton]
in all cases, and to provide a default implementation ofresult
for users to override if they want this feature.