-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Description
Once we're all wrapped up with the initial string context handling support, we need to decide what we want to do moving forward to make it less likely a context misuse can slip in. Two concrete proposals:
- Have the core
NixStringmanipulation functions be named in such a way as to indicate their proper use, and detailed haddocks on the functions andNixStringitself to describe how things should be used. - Use types to represent the different cases, requiring all creation or consumption of
NixStrings to go through these:
a.newtype ContextlessString = CS TextwhoseFromValueraises an error if the string has context and whoseToValuejust makes a string without context
b.newtype IntentionallyIgnoredContextString = IICS TextwhoseFromValueignores string context
c.data StorePathString = SPS TextwhoseToValuemakes a string with singleton context from the string's value
d.data StringWithContext = SWC Text (Set Context)to get the full access.
We could go even further here and have something likenewtype RelevanceProof a = Relevant aandtype StringWithContext = (forall t . (Text, Tagged t (Set Context)) -> (a, RelevanceProof (Tagged t (Set Context)) -> NixString -> ato "require" users to actually do something with the context 😉
My gut is saying we should just do 1, but curious @jwiegley and @mightybyte 's thoughts?
Metadata
Metadata
Assignees
Labels
No labels