For this issue, update the type signature of acopy and amap so that instead of taking header and data transform inputs, they take Formats.t as an input. The type signature should work out to something approximately like this:
val acopy : Formats.t -> parsetree -> (parsetree, Formats.error) result
The new behavior should be: whenever acopy [amap] hits on an attachment, it consults the Formats.t dictionary to see which format conversions to perform on that attachment (if any).
Error handling
This will also involve introducing some error handling into acopy and amap. For this issue, we don't need tons of error handling: just the basics corresponding to whatever error possibilities exist in the code from issue #9. As of right now, it looks like the only error possibilities we have in Formats.Error.t are a refer parse error and a config file parse error. I'll leave it to the assignee's discretion whether they want to e.g.:
introduce a Lib.Error sum type that tagged union-s Formats.Error.t-s and another error datatype defined for email parse errors, mbox parsing errors, and so forth
for now, make the simplifying assumption that the only kind of error you can have is a config file parse error, leaving email parsing error handling for a later issue
just stick one or two basic email parsing errors into Formats.Error.t
I'll mention that if we decide to make a global Lib.Error.t datatype, that feels like a great use case for a row sum type, i.e. polymorphic variants. That should allow us to "split up" the error cases between different modules, but have all the variants trace back to a single error datatype.
Anyway, I leave it to the assignee's discretion exactly how much of the error handling rabbit hole to go down for this issue.
Update
acopy
andamap
to fit config specFor this issue, update the type signature of
acopy
andamap
so that instead of taking header and data transform inputs, they takeFormats.t
as an input. The type signature should work out to something approximately like this:The new behavior should be: whenever
acopy
[amap
] hits on an attachment, it consults theFormats.t
dictionary to see which format conversions to perform on that attachment (if any).Error handling
This will also involve introducing some error handling into
acopy
andamap
. For this issue, we don't need tons of error handling: just the basics corresponding to whatever error possibilities exist in the code from issue #9. As of right now, it looks like the only error possibilities we have inFormats.Error.t
are a refer parse error and a config file parse error. I'll leave it to the assignee's discretion whether they want to e.g.:Lib.Error
sum type that tagged union-sFormats.Error.t
-s and another error datatype defined for email parse errors, mbox parsing errors, and so forthFormats.Error.t
I'll mention that if we decide to make a global
Lib.Error.t
datatype, that feels like a great use case for a row sum type, i.e. polymorphic variants. That should allow us to "split up" the error cases between different modules, but have all the variants trace back to a single error datatype.Anyway, I leave it to the assignee's discretion exactly how much of the error handling rabbit hole to go down for this issue.