Skip to content

Instantly share code, notes, and snippets.

@harms
Created March 8, 2012 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harms/1997868 to your computer and use it in GitHub Desktop.
Save harms/1997868 to your computer and use it in GitHub Desktop.
J akin to a Scala Option example.
NB. preparatory
OrFailureReport=: adverb : ' u ` asFailure @. fails '
UnlessFailed=: adverb : ' u ` ] @. fails '
NotingUnknownParsingError=: ::((makeFailure 'Unknown error in parsing attempt.')"_)
FAILMARK=: < s:'`_|_' NB. arbitrary
makeFailure=: [: < FAILMARK ; < :[:
fails=: [:+./ [:flatten (FAILMARK e. ]) L:1
NB. main
respond =: (asFile OrFailureReport) @: qualifyFile @: qualifyRequest
asFile =: 200 ; ]
asFailure=: 400 ; formatErrors
qualifyFile =: parseFile NotingUnknownParsingError UnlessFailed
qualifyRequest =: getSheet, getCustCode, getAttachment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment