A Pure Functional Psd To Png Converter in FSharp
A bare bones program for converting PSD files to PNG images, written in FSharp. Only designed for a very simple PSD file with specific parameters, but expansion should be pretty straight forward. File must be single layer with RGBA color, 8-bit depth, and can only be compressed using the packbits method. The resulting PNG merely conforms to the standard, performing no actual compression or other optimizations. Still, not bad for only two weeks worth of work!
What makes this program worth looking at is the code. For performance sake, the binary data should really be stored in arrays, but lists still work beautifully well when used appropriately. The fact that they're accessed from the front with their head/tail architecture fits the way a binary file is read and also enforces incredibly elegant and expressive programming patterns. Every looping need is achieved with recursion expressions that capture the essence of what lists are about. A particular gem worth checking out is my pure functional implementation of the Adler32 algorithm. It illustrates how the functional perspective can reduce convoluted imperative instructions to simple mathematics. It's also very efficient thanks to tail recursion and a convenient use of subtraction to reduce the number of list-summing operations from the length of the list to 1!