Converting height map bitmap to json This is my first F# program. 

It's a command line utility that takes a parameter containing a path to an height map bitmap and prints out this height map converted to JSON format.

open System.Drawing

let convertLine (y:int) (bitmap:System.Drawing.Bitmap) =
    [ for x in 0 .. bitmap.Width - 1 -&gt; "\"" + bitmap.GetPixel(x, y).R.ToString() + "\"" ] |&gt; String.concat ", "

let convert (path:string) : string = 
    let bitmap = new System.Drawing.Bitmap(path)
    let results = [ for y in 0 .. bitmap.Height - 1 -&gt; convertLine y bitmap ] |&gt; String.concat ", "

    "{\"X\": \"" + bitmap.Width.ToString() + 
    "\", \"Y\": \"" + bitmap.Width.ToString() + 
    "\", \"values\":[" + results + "]}"

[&lt;EntryPoint&gt;]
let main argv = 
    let arglist = argv |&gt; List.ofSeq

    let returnValue = 
        match arglist with
            | path :: _ -&gt; convert path
            | _ -&gt; "Wrong number of arguments supplied"

    printfn "%s" returnValue

    match returnValue with
        | "Wrong number of arguments supplied" -&gt; 1
        | _ -&gt; 0


I want to make sure to write idiomatic F# and to write in a functional style.
So I would make some changes:

let returnValue = 
    match arglist with
        | path :: _ -&gt; convert path
        | _ -&gt; "Wrong number of arguments supplied"


should probably be something like

let returnValue = 
    match arglist with
        | path :: _ -&gt; convert path
        | _ -&gt;failwith "Wrong number of arguments supplied"


which would simplify some logic

I would also change the printing to use sprintf

"{\"X\": \"" + bitmap.Width.ToString() + 
"\", \"Y\": \"" + bitmap.Width.ToString() + 
"\", \"values\":[" + results + "]}"


becomes

sprintf "{\"X\": \"%i\", \"Y\": \"%i\", \"values\":[%s]}" (bitmap.Width.ToString() ) (bitmap.Width.ToString() ) results