开发者

What is ASP.net in terms of FP?

Maybe I'll look strange. Feel free to edit etc. What is ASP.net in terms of FP?

I'm learning FP at the moment and feel rather confused because i cannot divide technology which I use everyday, literally ASP.Net - into some logical parts in terms of FP.

Now I treat all ASP.Net machine is like a big state monad, for which I usually use OnPreRender like point of calling ASP-net agnostic code. I treat aspx like kind of metaprogramming. What is user-control? Custom-control? What contexts (function environments) should we distinguish - http context? control context? page 开发者_JAVA百科context? Maybe I cannot see something obvious like treating page handlers == delegates == lambdas? Am I basically right? Could anybody suggest more fresh look onto ASP.Net - especially classical one?

It doesn't make sense to know that 'web-forms-suck' - I would like to know how should I use a power and 'turing-complete'ness of FP in this particular environment.


You could think of it like this, but I'm not sure that is too helpful. The problem is ASP.Net wasn't itself written in a functional style.

It would be far easier and useful to begin viewing the things you write (in any framework / language) in terms of side effects and functional composition. Begin to rely on state less (except, in ASP.Net where you must) and instead begin to think in terms of immutable data, inputs and outputs.

As a small example, instead of thinking in terms of modifying my string with contatenation, begin using functions (methods) like String.format instead. Small things like this will help in a big way when trying to apply a functional style to an OO environment.

To really begin to benefit from your FP learning, try thinking in terms of composition and composability (real word??) rather than in terms of OO hierarchies and inheritance.


ASP.Net is a kind of IO monad. The kinds of IO actions available in the monad are ones that read from HTTP requests and write to HTTP responses.

It might be educational to look at a web application server written in a purely functional language. Happstack is written entirely in Haskell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜