The algorithm, the type system, and some of the logical background are explained in this tutorial, along with an implementation in standard ML.
http://steshaw.org/hm/hindley-milner.pdf I found this 30 page PDF document very helpful in understanding the Algorithm.