Skip to content

monad-inspired hash parsing with good error reporting

Notifications You must be signed in to change notification settings

daniel-barlow/stitchup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stitchup

This is a fresh look at an actual problem: how Updraft parses its incoming document creation requests. Presently this is tackled in a rather ad-hoc way, in that there are a number of underspecified hashes, we signal invalid data by raising exceptions, and we sometimes get validation errors in unexpected places.

The approach here is:

  • "Parse, don't validate" - everywhere that we check an input is well-specified, we also convert the external representation into the object we actually need

  • inspired by monads, but is possibly not actually compliant with the monad laws. (Yes, this is why we have the rather opaque method names unit and lift)

The biggest ugliness in this right now is that the Result type might hold a hash or an array and you have to know which of them you've been handed in order to know how to use it, which seems kind of ungainly. Look in template.rb to see what I mean

Start by reading spec/stitchup/template_spec.rb to see how it hangs together

See also

Some of these links are marked [SB] meaning they are (or, at least, should be ;-) accessible only to @simplybusiness folk

About

monad-inspired hash parsing with good error reporting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages