Offer type refinements on return types #67
Labels
api
Relates to the API design
enhancement
An improvement to existing functionality
minor
Has only a small impact for the majority of users
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.The text was updated successfully, but these errors were encountered: