A neural network is actually just a huge function with many parameters, so you might think that it would be beautiful to write such a function in a functional language, but having worked on some NN libraries for other languages, I have certain doubts about how to implement them efficiently in this paradigm.
Passing around information: If you make a graph of the dependencies of each neuron or layer, you get something like this
where x is the input, and f is the output. While it looks pretty straight forward in the graph, if you really treat the network as a function then f has to pass the input (plus a subset of the weight parameters) to g1 and g2, each of them has to pass these to h1, h2 and h3 who finally send the result to the layer above. Taking into account that the set of inputs plus the set of weight could be a thousand or more variables, this looks highly inefficient. In other languages you wouldn't have to do this since each neuron could preserve it's parameters, and the inputs could be passed directly to the input layer.
States: If you look at the graph, both g1 and g2 are going to separately call h2, but since h2 has to yield the same value for both, it doesn't make sense to compute its output twice. Since you don't have state's or side effects this becomes tricky, and if you have a really huge network then even with some parallel computations this is going to waste a lot of time.
Lastly, when I say that the network is generic, I mean that it can have an arbitrary shape as long as its structure doesn't contain cycles. Most libraries I've seen use a stack of layers so you just have to define the number of layer and the number of neuron in each layer, but its shape is a linear graph; this is fine for simple applications, but really hard core stuff needs networks with more complex architectures
Id like some advice in how to attack these problems since I would like to implement a library for my own needs.
Note:
I am not totally new to to language. I've used a fair amount of Functors and Monads (mostly in my FP library for C# based on haskells API), but I've never used haskell for a real application before.
Update
The State
monad seems very promising!