-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Hello,
I have a naive question (my Haskell is rusty, so bear with me). I have a strict Data.Map.Map type like Map OsPath MyType
. (The MyType
is just a record I have in my program and not material to this discussion.) Anyway, I want to write this map as a JSON value to disk, like foo.json
. However I get an error from Data.Aeson about how there is no ToJSONKey
instance for the OsPath
type.
I have two questions:
- Would it make sense for this library to add a
ToJSONKey
instance forOsPath
? IIUC this library saves the raw bytes into OsPath (not caring about encoding), while still taking care to note path separators. So theoretically it appears to me that we could print out these raw bytes (and path separators) as some sort of compound JSON value. It definitely won't be as pretty as writing a basicString
(e.g.FilePath
) value, but at least it's something...? - Assuming the above is a bad idea, what is the recommended workaround? In particular my application reads files from disk, and I am basically saving the path from which the file was read as an
OsPath
(and parsing the contents as aMyType
). I just want to use OsPath everywhere because I really enjoy the fact that the type system makes it clear how it's not just aString
equivalent (which I've always disliked aboutFilePath
). Any specific guidance here would be appreciated.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels