简体   繁体   English

开始使用 Haskell

[英]Getting started with Haskell

For a few days I've tried to wrap my head around the functional programming paradigm in Haskell.几天来,我一直试图围绕 Haskell 中的函数式编程范例进行思考。 I've done this by reading tutorials and watching screencasts, but nothing really seems to stick.我通过阅读教程和观看截屏视频来做到这一点,但似乎没有什么能坚持下来。 Now, in learning various imperative/OO languages (like C, Java, PHP), exercises have been a good way for me to go.现在,在学习各种命令式/OO 语言(如 C、Java、PHP)时,练习对我来说是一个很好的方法。 But since I don't really know what Haskell is capable of and because there are many new concepts to utilize, I haven't known where to start.但是因为我真的不知道 Haskell 有什么能力,并且因为有很多新概念可以使用,所以我不知道从哪里开始。

So, how did you learn Haskell?那么,你是如何学习 Haskell 的呢? What made you really "break the ice"?是什么让你真正“破冰”? Also, any good ideas for beginning exercises?另外,对于开始练习有什么好主意吗?

I'm going to order this guide by the level of skill you have in Haskell, going from an absolute beginner right up to an expert.我将根据您在 Haskell 中的技能水平订购本指南,从绝对初学者到专家。 Note that this process will take many months (years?), so it is rather long.请注意,此过程将花费数月(数年?),因此相当长。

Absolute Beginner绝对的菜鸟

Firstly, Haskell is capable of anything, with enough skill.首先,Haskell 可以做任何事情,只要有足够的技能。 It is very fast (behind only C and C++ in my experience), and can be used for anything from simulations to servers, guis and web applications.它非常快(以我的经验仅落后于 C 和 C++),可用于从模拟到服务器、GUI 和 Web 应用程序的任何内容。

However there are some problems that are easier to write for a beginner in Haskell than others.然而,对于 Haskell 初学者来说,有些问题比其他问题更容易编写。 Mathematical problems and list process programs are good candidates for this, as they only require the most basic of Haskell knowledge to be able to write.数学问题和列表过程程序是很好的候选者,因为它们只需要最基本的 Haskell 知识就可以编写。

Some good guides to learning the very basics of Haskell are the Happy Learn Haskell Tutorial and the first 6 chapters of Learn You a Haskell for Great Good (or its JupyterLab adaptation ).学习 Haskell 基础知识的一些很好的指南是Happy Learn Haskell 教程Learn You a Haskell for Great Good (或其JupyterLab 改编版)的前 6 章。 While reading these, it is a very good idea to also be solving simple problems with what you know.在阅读这些内容时,用你所知道的来解决简单的问题是一个很好的主意。

Another two good resources are Haskell Programming from first principles , and Programming in Haskell .另外两个很好的资源是Haskell Programming from First PrinciplesProgramming in Haskell They both come with exercises for each chapter, so you have small simple problems matching what you learned on the last few pages.它们每章都带有练习,所以你有一些简单的小问题,与你在最后几页学到的东西相匹配。

A good list of problems to try is the haskell 99 problems page .一个很好的问题列表是haskell 99 问题页面 These start off very basic, and get more difficult as you go on.这些从非常基本的开始,随着您的进行而变得更加困难。 It is very good practice doing a lot of those, as they let you practice your skills in recursion and higher order functions.做很多这些是非常好的练习,因为它们可以让您练习递归和高阶函数的技能。 I would recommend skipping any problems that require randomness as that is a bit more difficult in Haskell.我建议跳过任何需要随机性的问题,因为这在 Haskell 中有点困难。 Check this SO question in case you want to test your solutions with QuickCheck (see Intermediate below).如果您想使用 QuickCheck 测试您的解决方案,请检查此 SO 问题(请参阅下面的中级)。

Once you have done a few of those, you could move on to doing a few of the Project Euler problems.一旦你完成了其中的一些,你就可以继续解决一些Project Euler问题。 These are sorted by how many people have completed them, which is a fairly good indication of difficulty.这些按完成的人数排序,这是一个相当好的难度指示。 These test your logic and Haskell more than the previous problems, but you should still be able to do the first few.这些比之前的问题更能测试你的逻辑和 Haskell,但你应该仍然可以做前几个。 A big advantage Haskell has with these problems is Integers aren't limited in size. Haskell 解决这些问题的一大优势是整数不受大小限制。 To complete some of these problems, it will be useful to have read chapters 7 and 8 of learn you a Haskell as well.为了完成其中的一些问题,阅读第 7 章和第 8 章学习 Haskell 会很有用。

Beginner初学者

After that you should have a fairly good handle on recursion and higher order functions, so it would be a good time to start doing some more real world problems.在那之后,你应该对递归和高阶函数有相当好的掌握,所以现在是开始解决一些更现实世界问题的好时机。 A very good place to start is Real World Haskell (online book, you can also purchase a hard copy).一个很好的起点是Real World Haskell (在线书籍,您也可以购买硬拷贝)。 I found the first few chapters introduced too much too quickly for someone who has never done functional programming/used recursion before.我发现前几章对于以前从未进行过函数式编程/使用递归的人来说介绍得太快了。 However with the practice you would have had from doing the previous problems you should find it perfectly understandable.但是,通过您在之前的问题中所获得的练习,您应该会发现它完全可以理解。

Working through the problems in the book is a great way of learning how to manage abstractions and building reusable components in Haskell.解决本书中的问题是学习如何在 Haskell 中管理抽象和构建可重用组件的好方法。 This is vital for people used to object-orientated (oo) programming, as the normal oo abstraction methods (oo classes) don't appear in Haskell (Haskell has type classes, but they are very different to oo classes, more like oo interfaces).这对于习惯于面向对象(oo)编程的人来说至关重要,因为正常的 oo 抽象方法(oo 类)不会出现在 Haskell 中(Haskell 有类型类,但它们与 oo 类非常不同,更像是 oo 接口)。 I don't think it is a good idea to skip chapters, as each introduces a lot new ideas that are used in later chapters.我不认为跳过章节是一个好主意,因为每个章节都引入了很多在后面章节中使用的新想法。

After a while you will get to chapter 14, the dreaded monads chapter (dum dum dummmm).一段时间后,您将进入第 14 章,即可怕的 monad 章节 (dum dum dummmm)。 Almost everyone who learns Haskell has trouble understanding monads, due to how abstract the concept is.由于概念太抽象,几乎所有学习 Haskell 的人都难以理解 monad。 I can't think of any concept in another language that is as abstract as monads are in functional programming.我想不出另一种语言中的任何概念像函数式编程中的 monad 一样抽象。 Monads allows many ideas (such as IO operations, computations that might fail, parsing,...) to be unified under one idea. Monads 允许将许多想法(例如 IO 操作、可能失败的计算、解析等)统一到一个想法下。 So don't feel discouraged if after reading the monads chapter you don't really understand them.因此,如果您在阅读了 monad 章节后还没有真正理解它们,请不要气馁。 I found it useful to read many different explanations of monads;我发现阅读许多关于 monad 的不同解释很有用; each one gives a new perspective on the problem.每个人都对这个问题提出了新的看法。 Here is a very good list of monad tutorials .这是一个非常好的monad 教程列表 I highly recommend the All About Monads , but the others are also good.我强烈推荐All About Monads ,但其他的也不错。

Also, it takes a while for the concepts to truly sink in. This comes through use, but also through time.此外,概念真正融入需要一段时间。这来自使用,也来自时间。 I find that sometimes sleeping on a problem helps more than anything else!我发现有时在一个问题上睡觉比什么都重要! Eventually, the idea will click, and you will wonder why you struggled to understand a concept that in reality is incredibly simple.最终,这个想法会被点击,你会想知道为什么你很难理解一个实际上非常简单的概念。 It is awesome when this happens, and when it does, you might find Haskell to be your favorite imperative programming language :)当这种情况发生时真是太棒了,当它发生时,您可能会发现 Haskell 是您最喜欢的命令式编程语言 :)

To make sure that you are understanding Haskell type system perfectly, you should try to solve 20 intermediate haskell exercises .为了确保您完全理解 Haskell 类型系统,您应该尝试解决20 个中级Haskell 练习 Those exercises using fun names of functions like "furry" and "banana" and helps you to have a good understanding of some basic functional programming concepts if you don't have them already.这些练习使用有趣的函数名称,例如“furry”和“banana”,如果您还没有的话,可以帮助您很好地理解一些基本的函数式编程概念。 Nice way to spend your evening with a bunch of papers covered with arrows, unicorns, sausages and furry bananas.用一堆布满箭头、独角兽、香肠和毛茸茸的香蕉的纸来度过你的夜晚的好方法。

Intermediate中间的

Once you understand Monads, I think you have made the transition from a beginner Haskell programmer to an intermediate haskeller.一旦你理解了 Monads,我认为你已经从一个初学者 Haskell 程序员过渡到一个中级 Haskell 程序员。 So where to go from here?那么从这里去哪里呢? The first thing I would recommend (if you haven't already learnt them from learning monads) is the various types of monads, such as Reader, Writer and State.我要推荐的第一件事(如果您还没有从学习 monad 中学到它们)是各种类型的 monad,例如 Reader、Writer 和 State。 Again, Real world Haskell and All about monads gives great coverage of this.同样,Real world Haskell 和 All about monads 对此进行了大量报道。 To complete your monad training learning about monad transformers is a must.要完成您的 monad 培训,必须学习有关 monad 转换器的知识。 These let you combine different types of Monads (such as a Reader and State monad) into one.这些使您可以将不同类型的 Monad(例如 Reader 和 State monad)合二为一。 This may seem useless to begin with, but after using them for a while you will wonder how you lived without them.一开始这似乎没什么用,但是在使用它们一段时间后,您会想知道没有它们您是如何生活的。

Now you can finish the real world Haskell book if you want.现在,如果您愿意,您可以完成现实世界的 Haskell 书籍。 Skipping chapters now doesn't really matter, as long as you have monads down pat.现在跳过章节并不重要,只要你有单子。 Just choose what you are interested in.只需选择您感兴趣的内容即可。

With the knowledge you would have now, you should be able to use most of the packages on cabal (well the documented ones at least...), as well as most of the libraries that come with Haskell.凭借您现在拥有的知识,您应该能够使用 cabal 上的大多数软件包(至少有文档记录的软件包......),以及 Haskell 附带的大多数库。 A list of interesting libraries to try would be:要尝试的有趣库列表是:

  • Parsec : for parsing programs and text. Parsec :用于解析程序和文本。 Much better than using regexps.比使用正则表达式要好得多。 Excellent documentation, also has a real world Haskell chapter.优秀的文档,还有真实世界的 Haskell 章节。

  • QuickCheck : A very cool testing program. QuickCheck :一个非常酷的测试程序。 What you do is write a predicate that should always be true (eg length (reverse lst) == length lst ).您所做的是编写一个应始终为真的谓词(例如length (reverse lst) == length lst )。 You then pass the predicate the QuickCheck, and it will generate a lot of random values (in this case lists) and test that the predicate is true for all results.然后将谓词传递给 QuickCheck,它将生成大量随机值(在本例中为列表)并测试该谓词对于所有结果是否为真。 See also the online manual .另请参阅在线手册

  • HUnit : Unit testing in Haskell. HUnit :Haskell 中的单元测试。

  • gtk2hs : The most popular gui framework for Haskell, lets you write gtk applications. gtk2hs :Haskell 最流行的 gui 框架,可让您编写 gtk 应用程序。

  • happstack : A web development framework for Haskell. happstack :Haskell 的 Web 开发框架。 Doesn't use databases, instead a data type store.不使用数据库,而是使用数据类型存储。 Pretty good docs (other popular frameworks would be snap and yesod ).非常好的文档(其他流行的框架是snapyesod )。

Also, there are many concepts (like the Monad concept) that you should eventually learn.此外,您最终应该学习许多概念(如 Monad 概念)。 This will be easier than learning Monads the first time, as your brain will be used to dealing with the level of abstraction involved.这将比第一次学习 Monad 更容易,因为您的大脑将习惯于处理所涉及的抽象级别。 A very good overview for learning about these high level concepts and how they fit together is the Typeclassopedia .了解这些高级概念以及它们如何组合在一起的一个很好的概述是Typeclassopedia

  • Applicative: An interface like Monads, but less powerful.适用:类似于 Monads 的接口,但功能较弱。 Every Monad is Applicative, but not vice versa.每个 Monad 都是 Applicative,但反之则不然。 This is useful as there are some types that are Applicative but are not Monads.这很有用,因为有些类型是 Applicative 但不是 Monad。 Also, code written using the Applicative functions is often more composable than writing the equivalent code using the Monad functions.此外,使用 Applicative 函数编写的代码通常比使用 Monad 函数编写等效代码更具组合性。 See Functors, Applicative Functors and Monoids from the learn you a haskell guide.请参阅学习您的 Haskell 指南中的Functors、Applicative Functors 和 Monoids

  • Foldable , Traversable : Typeclasses that abstract many of the operations of lists, so that the same functions can be applied to other container types. Foldable , Traversable :抽象列表的许多操作的类型类,以便相同的功能可以应用于其他容器类型。 See also the haskell wiki explanation .另请参阅haskell wiki 解释

  • Monoid : A Monoid is a type that has a zero (or mempty) value, and an operation, notated <> that joins two Monoids together, such that x <> mempty = mempty <> x = x and x <> (y <> z) = (x <> y) <> z . Monoid : Monoid 是一种具有零(或 mempty)值的类型,以及一个操作,用<>表示,将两个 Monoid 连接在一起,这样x <> mempty = mempty <> x = xx <> (y <> z) = (x <> y) <> z These are called identity and associativity laws.这些被称为恒等律和结合律。 Many types are Monoids, such as numbers, with mempty = 0 and <> = + .许多类型是mempty = 0 ,例如数字,具有mempty = 0<> = + This is useful in many situations.这在很多情况下都很有用。

  • Arrows : Arrows are a way of representing computations that take an input and return an output.箭头:箭头是表示接受输入并返回输出的计算的一种方式。 A function is the most basic type of arrow, but there are many other types.函数是最基本的箭头类型,但还有许多其他类型。 The library also has many very useful functions for manipulating arrows - they are very useful even if only used with plain old Haskell functions.该库还有许多非常有用的操作箭头的函数——即使只与普通的旧 Haskell 函数一起使用,它们也非常有用。

  • Arrays : the various mutable/immutable arrays in Haskell.数组:Haskell 中的各种可变/不可变数组。

  • ST Monad : lets you write code with a mutable state that runs very quickly, while still remaining pure outside the monad. ST Monad :让您编写具有可变状态的代码,该代码运行速度非常快,同时在 monad 之外仍保持纯净。 See the link for more details.请参阅链接查看更多细节。

  • FRP: Functional Reactive Programming, a new, experimental way of writing code that handles events, triggers, inputs and outputs (such as a gui). FRP:Functional Reactive Programming,一种新的、实验性的编写处理事件、触发器、输入和输出(例如 gui)代码的方法。 I don't know much about this though.不过我对这件事了解不多。 Paul Hudak's talk about yampa is a good start. Paul Hudak 关于 yampa 的演讲是一个好的开始。

There are a lot of new language features you should have a look at.有很多新的语言特性你应该看看。 I'll just list them, you can find lots of info about them from google, the haskell wikibook , the haskellwiki.org site and ghc documentation .我只会列出它们,您可以从 google、 haskell wikibook、haskellwiki.org 站点和ghc 文档中找到很多关于它们的信息。

  • Multiparameter type classes/functional dependencies多参数类型类/函数依赖
  • Type families类型族
  • Existentially quantified types存在量化类型
  • Phantom types幻影类型
  • GADTS GADTS
  • others...其他...

A lot of Haskell is based around category theory , so you may want to look into that.许多 Haskell 都基于类别理论,因此您可能需要研究一下。 A good starting point is Category Theory for Computer Scientist .一个很好的起点是计算机科学家的范畴论 If you don't want to buy the book, the author's related article is also excellent.如果你不想买书,作者的相关文章也很棒。

Finally you will want to learn more about the various Haskell tools.最后,您将想要了解有关各种 Haskell 工具的更多信息。 These include:这些包括:

  • ghc (and all its features) ghc (及其所有功能)
  • cabal : the Haskell package system cabal : Haskell 包系统
  • darcs : a distributed version control system written in Haskell, very popular for Haskell programs. darcs :一个用 Haskell 编写的分布式版本控制系统,在 Haskell 程序中非常流行。
  • haddock : a Haskell automatic documentation generator haddock : Haskell 自动文档生成器

While learning all these new libraries and concepts, it is very useful to be writing a moderate-sized project in Haskell.在学习所有这些新的库和概念的同时,用 Haskell 编写一个中等规模的项目是非常有用的。 It can be anything (eg a small game, data analyser, website, compiler ).它可以是任何东西(例如小游戏、数据分析器、网站、 编译器)。 Working on this will allow you to apply many of the things you are now learning.在这方面工作将使您能够应用您现在正在学习的许多东西。 You stay at this level for ages (this is where I'm at).你在这个水平上停留了很长时间(这就是我所处的位置)。

Expert专家

It will take you years to get to this stage (hello from 2009!), but from here I'm guessing you start writing phd papers, new ghc extensions, and coming up with new abstractions.到达这个阶段需要数年时间(你好,从 2009 年开始!),但从这里我猜你开始写博士论文,新的 ghc 扩展,并提出新的抽象。

Getting Help获得帮助

Finally, while at any stage of learning, there are multiple places for getting information.最后,在学习的任何阶段,都有多个获取信息的地方。 These are:这些是:

  • the #haskell irc channel #haskell irc 频道
  • the mailing lists .邮件列表 These are worth signing up for just to read the discussions that take place - some are very interesting.这些值得注册只是为了阅读发生的讨论 - 有些非常有趣。
  • other places listed on the haskell.org home page haskell.org 主页上列出的其他地方

Conclusion结论

Well this turned out longer than I expected... Anyway, I think it is a very good idea to become proficient in Haskell.嗯,结果比我预期的要长......无论如何,我认为精通 Haskell 是一个非常好的主意。 It takes a long time, but that is mainly because you are learning a completely new way of thinking by doing so.这需要很长时间,但这主要是因为你正在学习一种全新的思维方式。 It is not like learning Ruby after learning Java, but like learning Java after learning C. Also, I am finding that my object-orientated programming skills have improved as a result of learning Haskell, as I am seeing many new ways of abstracting ideas.这不像是先学Java再学Ruby,而是先学C再学Java。另外,我发现我的面向对象编程技能由于学习了Haskell而有所提高,因为我看到了许多抽象思想的新方法。

Some colleague of mine had good experience with Learn You a Haskell for Great Good!我的一些同事在Learn You a Haskell for Great Good方面有很好的经验 . .

Tutorial aimed at people who have experience in imperative programming languages but haven't programmed in a functional language before.本教程面向具有命令式编程语言经验但之前未使用函数式语言进行编程的人员。

And check the answers here too并在这里检查答案

Here's a good book that you can read online: Real World Haskell这是一本可以在线阅读的好书: Real World Haskell

Most of the Haskell programs I've done have been to solve Project Euler problems.我做过的大部分 Haskell 程序都是为了解决Project Euler问题。

Once piece of advice I read not too long ago was that you should have a standard set of simple problems you know how to solve (in theory) and then whenever you try to learn a new language you implement those problems in that language.我不久前读到的一条建议是,你应该有一套标准的简单问题,你知道如何解决(理论上),然后每当你尝试学习一门新语言时,你就用那种语言来解决这些问题。

I enjoyed watching this 13 episode series on Functional Programming using Haskell.我很喜欢看这个关于使用 Haskell 进行函数式编程的 13 集系列。

C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals: http://channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/ C9 讲座:Erik Meijer 博士 - 函数式编程基础: http : //channel9.msdn.com/shows/Going+Deep/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1/

To add on others' answers - there is one useful that will help you when coding (for example when solving project Euler problems): Hoogle .添加其他人的答案 - 在编码时(例如在解决项目 Euler 问题时)有一个有用的方法可以帮助您: Hoogle You can use either the command line interface or the web interface .您可以使用命令行界面或Web 界面

Command Line命令行

After you installed the Haskell platform be sure to cabal install hoogle安装 Haskell 平台后,请务必cabal install hoogle

Hoogle usage example: Hoogle 使用示例:

You have a function fx = 3 * x + 1 and you want to apply it on (5 :: Int) , then apply it on the result and on that result and so on and get an infinite list of those values.您有一个函数fx = 3 * x + 1并且您想将其应用于(5 :: Int) ,然后将其应用于结果和该结果等等,并获得这些值的无限列表。 You suspect there might already exist a function to assist you (not specifically for your f though).你怀疑可能已经存在一个功能来帮助你(虽然不是专门为你的f )。

That function would be of type (a -> a) -> a -> [a] if it takes f 5 or a -> (a -> a) -> [a] if it takes 5 f (we assume the function is for general types and not just Int s)该函数的类型为(a -> a) -> a -> [a]如果需要f 5a -> (a -> a) -> [a]如果需要5 f (我们假设函数用于一般类型,而不仅仅是Int s)

$ hoogle "a -> (a -> a) -> [a]"
Prelude iterate :: (a -> a) -> a -> [a]

yep, the function you need already exists and it's called iterate .是的,你需要的函数已经存在,它被称为iterate you use it by iterate func 5 !你通过iterate func 5使用它!

Web interface网页界面

The result for the same example can be found here .可以在此处找到相同示例的结果

Graham Hutton's Programming in Haskell is concise, reasonably thorough, and his years of teaching Haskell really show. Graham Hutton 的Programming in Haskell简明扼要,相当彻底,而且他多年教授 Haskell 的经历也很真实。 It's almost always what I recommend people start with, regardless of where you go from there.无论您从哪里开始,这几乎总是我建议人们开始的内容。

In particular, Chapter 8 ("Functional Parsers") provides the real groundwork you need to start dealing with monads, and I think is by far the best place to start, followed by All About Monads .特别是,第 8 章(“函数解析器”)提供了开始处理 monad 所需的真正基础,我认为这是迄今为止最好的起点,其次是All About Monads (With regard to that chapter, though, do note the errata from the web site, however: you can't use the do form without some special help. You might want to learn about typeclasses first and solve that problem on your own.) (不过,关于那一章,请注意网站上的勘误表:如果没有特殊帮助,您将无法使用do形式。您可能想先了解类型类并自行解决该问题。)

This is rarely emphasized to Haskell beginners, but it's worth learning fairly early on not just about using monads, but about constructing your own. Haskell 初学者很少强调这一点,但值得尽早学习,不仅是使用 monad,而且是构建自己的。 It's not hard, and customized ones can make a number of tasks rather more simple.这并不难,定制的可以使许多任务变得更加简单。

Don't try to read all the monad tutorials with funny metaphors.不要试图阅读所有带有有趣隐喻的 monad 教程。 They will just get you mixed up even worse.他们只会让你混淆更糟。

I'd suggest joining the #haskell irc channel and asking questions there.我建议加入#haskell irc 频道并在那里提问。 That's how I learned Haskell.这就是我学习Haskell的方式。 If you go through Real World Haskell as suggested above, real time answers to your questions will help greatly.如果您按照上面的建议使用 Real World Haskell,那么对您的问题的实时回答将有很大帮助。 Lots of smart people on #haskell write Haskell for fun and for profit, so you'll get lots of good input.许多#haskell 上的聪明人为了好玩和盈利而编写 Haskell,所以你会得到很多好的输入。 Try it!尝试一下!

These are my favorite这些是我的最爱

Haskell: Functional Programming with Types Haskell:使用类型进行函数式编程

Joeri van Eekelen, et al. | Wikibooks
       Published in 2012, 597 pages

Real World Haskell真实世界 Haskell

   B. O'Sullivan, J. Goerzen, D. Stewart | OReilly Media, Inc.
   Published in 2008, 710 pages

I can additionally recommend Yet Another Haskell Tutorial as an introduction.我还可以推荐Yet Another Haskell 教程作为介绍。

Another good learning resource (probably on the intermediate level), which has helped me a lot and hasn't been mentioned in the other answers as far as I can see, is Brent Yorgey's Typeclassopedia , which can be found inThe Monad Reader (Issue 13)另一个很好的学习资源(可能在中级)对我帮助很大,据我所知在其他答案中没有提到,是 Brent Yorgey 的Typeclassopedia ,可以在The Monad Reader (Issue 13)

It is written in a very accessible style and contains (among many other things), the following introductory advice:它以一种非常易于理解的风格编写,并包含(除其他外)以下介绍性建议:

There are two keys to an expert Haskell hacker's wisdom: Haskell 黑客专家的智慧有两个关键:

  1. Understand the types.了解类型。

  2. Gain a deep intuition for each type class and its relationship to other type classes, backed up by familiarity with many examples.在熟悉许多示例的支持下,对每个类型类及其与其他类型类的关系获得深刻的直觉。

The Monad Reader itself is an absolute treasure trove for functional programmers (not only Haskell programmers). Monad Reader本身是函数式程序员(不仅是 Haskell 程序员)的绝对宝库。

Try writing easy programs in it.尝试在其中编写简单的程序。

You can find sample tasks in various textbooks, probably.您可能可以在各种教科书中找到示例任务。

I wouldn't recommend sticking to Haskell/FP textbooks, just try to do simple things with it: calculations, string manipulations, file access.我不建议坚持使用 Haskell/FP 教科书,只需尝试用它做简单的事情:计算、字符串操作、文件访问。

After I solved a dozen, I've broke the ice :)在我解决了十几个之后,我打破了僵局:)

After that, read a lot on advanced concepts (Monads, Arrows, IO, recursive data structures), because haskell is infinite and there are a lot of them.之后,阅读大量高级概念(Monads、Arrows、IO、递归数据结构),因为 haskell 是无限的,而且有很多。

I do think that realizing Haskell's feature by examples is the best way to start above all.我确实认为通过示例实现 Haskell 的特性是最好的开始方式。

http://en.wikipedia.org/wiki/Haskell_98_features http://en.wikipedia.org/wiki/Haskell_98_features

Here is tricky typeclasses including monads and arrows这是棘手的类型类,包括 monads 和箭头

http://www.haskell.org/haskellwiki/Typeclassopedia http://www.haskell.org/haskellwiki/Typeclassopedia

for real world problems and bigger project, remember these tags: GHC(most used compiler), Hackage(libraryDB), Cabal(building system), darcs(another building system).对于现实世界的问题和更大的项目,请记住这些标签:GHC(最常用的编译器)、Hackage(libraryDB)、Cabal(建筑系统)、darcs(另一个建筑系统)。

A integrated system can save your time: http://hackage.haskell.org/platform/集成系统可以节省您的时间: http : //hackage.haskell.org/platform/

the package database for this system: http://hackage.haskell.org/这个系统的包数据库: http : //hackage.haskell.org/

GHC compiler's wiki: http://www.haskell.org/haskellwiki/GHC GHC 编译器的 wiki: http : //www.haskell.org/haskellwiki/GHC

After Haskell_98_features and Typeclassopedia, I think you already can find and read the documention about them yourself在 Haskell_98_features 和 Typeclassopedia 之后,我想你已经可以自己找到并阅读有关它们的文档了

By the way, you may want to test some GHC's languages extension which may be a part of haskell standard in the future.顺便说一句,您可能想测试一些 GHC 的语言扩展,这些扩展可能在未来成为 Haskell 标准的一部分。

this is my best way for learning haskell.这是我学习haskell的最佳方式。 i hope it can help you.我希望它能帮助你。

I suggest that you first start by reading BONUS' tutorial , And then reading Real World Haskell (online for free) .我建议您首先阅读BONUS 的教程,然后阅读Real World Haskell(免费在线) Join the #Haskell IRC channel, on irc.freenode.com , and ask questions.加入irc.freenode.com 上#Haskell IRC 频道,并提出问题。 These people are absolutely newbie friendly, and have helped me a lot over time.这些人对新手绝对友好,并且随着时间的推移帮助了我很多。 Also, right here on SO is a great place to get help with things you can't grasp!此外,就在 SO 上,这里是获得帮助解决您无法掌握的问题的好地方! Try not to get discouraged, once it clicks, your mind will be blown.尽量不要气馁,一旦点击,你的头脑就会被吹走。

BONUS' tutorial will prime you up, and get you ready for the thrill ride that Real World Haskell brings. BONUS 的教程将为您做好准备,让您为 Real World Haskell 带来的惊险之旅做好准备。 I wish you luck!祝你好运!

If you only have experience with imperative/OO languages, I suggest using a more conventional functional language as a stepping stone.如果您只有命令式/面向对象语言的经验,我建议使用更传统的函数式语言作为垫脚石。 Haskell is really different and you have to understand a lot of different concepts to get anywhere. Haskell真的很不同,你必须理解很多不同的概念才能到达任何地方。 I suggest tackling a ML-style language (like eg F#) first.我建议首先处理 ML 风格的语言(例如 F#)。

The first answer is a very good one.第一个答案非常好。 In order to get to the Expert level, you should do a PhD with some of the Experts themselves.为了达到专家级别,您应该与一些专家一起攻读博士学位。

I suggest you to visit the Haskell page: http://haskell.org .我建议您访问 Haskell 页面: http : //haskell.org There you have a lot of material, and a lot of references to the most up-to-date stuff in Haskell, approved by the Haskell community.那里有很多材料,并且有很多对 Haskell 社区批准的最新内容的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM