真实世界的Haskell编程 [英] Real world Haskell programming

查看:329
本文介绍了真实世界的Haskell编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几年前,我终于决定学习Haskell 。这是一种非常酷的语言,但我对于如何以这种语言编写事件驱动真实应用程序感到困惑。你知道一个关于它的好教程吗?



注意:当我说真正的应用程序时,我没有谈论现实世界,生产准备应用程序。我只是指一个小样本应用程序,只是为了掌握它。我认为像windows caculator的简化版本会很棒,然后可能会更复杂一些。

当解决方案

当你说真实世界的例子,你大概是在思考那些固有的顺序或有状态的问题,或者做了很多I / O,对吧?



或者, X Window Manager ,可扩展的 Emacs克隆文本编辑器 IDE

然后,就是这本书,甚至在标题中已经有你的问题:真实世界Haskell ,它也是免费提供



另一件你可能想看的事情是 Functional Reactive Programming 。 (例如,它在Frag中使用。)关于FRP的一个有趣的事情是它允许您从一个非常不同的角度来看待GUI编程的问题。如果您阅读RWH手册中的GUI一章,您将会看到它谈到了如何像C一样编写GUI应用程序,只有更好。 FRP OTOH允许你用完全不同的方式编写它,甚至在C中不可能。



当有人说但Haskell可以在现实世界中使用时,很多时候(我并不是说你的问题就是这种情况,但它是一种反复出现的模式),它们是什么 / em>说的是我知道如何在C中做到这一点,而在Haskell中,我不能以完全相同的方式来完成这个任务,因此Haskell一定是不可能的,因此Haskell还没有为现实世界做好准备。但是他们错过的是,可能有一种完全不同的方法来解决这个问题。 (这就像是说Erlang没有线程,因此它不可能被用来实现并发系统。)而FRP就是一个例子。


Having been an imperative developer for some years now, I had never had the urge to learn functional programming.

A couple months ago at last I decided to learn Haskell. It's quite a cool language, but I'm puzzled about how an event driven real app would be programmed in such a language. Do you know of a good tutorial about it?

Note: When I say "real app" I'm not talking of a real world, production ready app. I just mean a little sample app, just to get the grasp of it. I think something like a simplified version of the windows caculator would be great, and then perhaps something a bit more complex.

解决方案

When you say "real world" examples you are presumably thinking about problems that are inherently sequential or stateful or do lots of I/O, right?

So, how about games?

Or, what about an X Window Manager, an extensible Emacs clone text editor or an IDE?

Then, there is the book, which even has your question already in the title: Real World Haskell and which is also available for free!

Another thing you might want to look at, is Functional Reactive Programming. (It is used in Frag, for example.) The interesting thing about FRP is that it allows you to look at the problem of, say, GUI programming from a very different angle. If you read the GUI chapter in the RWH book, you will see that it talks about how you can write a GUI application just like in C, only better. FRP OTOH allows you to write it in a totally different way that wouldn't even be possible in C.

A lot of times (I'm not saying that this is the case in your question, but it is a recurring pattern) when someone says "but can Haskell be used in the real world", what they are really saying is "I know how to do this in C, and in Haskell I cannot do it in exactly the same way, therefore it must be impossible in Haskell, therefore Haskell is not ready for the real world". But what they are missing out on, is that there might be a totally different and much better way to solve the problem. (It's like saying "Erlang doesn't have threads, therefore it cannot possibly be used to implement concurrent systems.") And FRP is just one example.

这篇关于真实世界的Haskell编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆