uchicago-library / attachment-converter

Attachment Converter: tool for batch converting attachments in an email mailbox
GNU General Public License v2.0
8 stars 3 forks source link

Update `acopy` and `amap` to fit config spec #17

Closed bufordrat closed 2 years ago

bufordrat commented 2 years ago

Update acopy and amap to fit config spec

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.:

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.

bufordrat commented 2 years ago

Merged in. w00t