是否有一个Haskell编译器或预处理器使用严格的评估? [英] Is there a Haskell compiler or preprocessor that uses strict evaluation?

查看:126
本文介绍了是否有一个Haskell编译器或预处理器使用严格的评估?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个Haskell编译器,默认使用严格的评估,而不是延迟评估。我只是使用OCaml,但Haskell的语法比OCaml更好(和Haskell是纯的,并有很酷的功能,如类型类)。



我真的不想经常在我的程序中加入 s和 $!。具有开关或预处理器的编译器放入严格性注释将是非常好的。如果有办法在某些地方使用惰性求值,也是有用的,只是为了防止我想要一个无限列表(我可能永远不会)。



请不要试图说服我懒惰的评价更好,我真的需要性能。 IIRC,Simon Peyton Jones甚至说懒惰的评价并不是真的有必要,它主要是为了防止他们使语言不纯。

解决方案

如果你有一个使用严格评估的Haskell编译器,它不会编译Haskell。 Laziness 非严格性是Haskell规范的一部分!



但是,还有其他选择。




I'm looking for a Haskell compiler that uses strict evaluation by default instead of lazy evaluation. I would just use OCaml, but Haskell's syntax is so much better than OCaml's (and Haskell is pure, and has cool features such as type classes).

I'd really rather not constantly put !s and $!s all over my program. A compiler with a switch or a preprocessor to put in the strictness annotations would be really nice. It would also be helpful if there was a way to use lazy evaluation in certain places too, just in case I want something like an infinite list (I probably never will).

Please do not try to convince me that lazy evaluation is better, I really need the performance. IIRC, Simon Peyton Jones even said that lazy evaluation wasn't really necessary, it was there mostly to prevent them from making the language impure.

解决方案

If you have a Haskell compiler that uses strict evaluation, it doesn't compile Haskell. Laziness Non-strictness is part of the Haskell spec!

However, there are alternatives.

  • DDC is an attempt to create an explicitly lazy variant of Haskell which supports things like destructive update whilst retaining all the rest of Haskell's goodness. There is one problem: the compiler is currently only in the α-stage, although it seems to be at least usable.

  • Create a preprocessor, as others have done.

  • Learn to use Haskell "the right way". If you can simplify your test case down to something which is publicly-displayable, you could post it on the Haskell-Café mailing list, where people are very helpful with these sorts of questions concerning the effects of non-strictness.

这篇关于是否有一个Haskell编译器或预处理器使用严格的评估?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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