Comment

Comment by glifchits

Looking at a random file in the Flow source [0]

      (* The entry point *)
      let rec go content =
        let env = { file = None; modified = []; line = 0; result = [] } in
        let lines = split_lines content in
        start env lines;
        match List.rev env.result with
        | [] -> []
        | _ :: results -> results

      (* Skip the text before the first +++ (to make things work with git show) *)
      and start env = function
        | [] -> ()
        | line :: lines
          when String.length line > 4 && String.sub line 0 3 = "+++" ->
            header env line;
            modified env 0 lines
        | _ :: lines -> start env lines
Its beautiful to me because its very concise looking, while still using a fair bit of real English, meaningful symbols, and idioms like [] makes an empty array or whatever. I have to admit, much of this is lost on me, but it does feel more accessible than other FP languages. It almost has a Python feel.

[0] https://github.com/facebook/flow/blob/master/hack/parsing/fo...

parent glifchits 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton