Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* How do I use a function with labeled arguments in an
- * applicative functor setting? *)
- let chorus ~count ~msgs =
- Printf.printf "chorus %d %s\n" count msgs
- (* The obvious solution is to convert my labelled arguments
- * to positional arguments when passing my function to cmdliner *)
- let chorus_t1 = Term.(
- pure (fun count msgs -> chorus ~count ~msgs) $
- count $ msgs)
- (* This other way I found lets you specify the arguments one at a time
- * using partial application... but it looks awful!
- * And the order is still fixed - it doesn't compile if you put the
- * "count" line after the "msgs" line *)
- let ($!) a b = Term.($) b a
- let chorus_t2 = Term.(
- pure chorus $!
- (count $! pure (fun x f -> f ~count:x)) $!
- (msgs $! pure (fun x f -> f ~msgs:x))
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement