haskell

技术沙龙|解读以太坊黄皮书,学习智能合约应用开发(北京)

拜拜、爱过 提交于 2020-03-01 04:14:17
前几天HiBlock区块链社区的杨镇老师在一次访谈中再次聊到了区块链技术学习和应用的话题,杨镇老师的观点很明确, 技术学习要回归本质,区块链应用要融入场景。 杨镇老师2017年初开始翻译以太坊Homestead官方文档,对以太坊黄皮书(以太坊技术手册)中文版进行独立校订和增补更新,并且独立翻译了以太坊分片技术说明,他认为:“了解以太坊,最好的方式是学习官方技术文档,也就是以太坊黄皮书”。他的这一观点与很多技术专家都不谋而合。 HiBlock区块链社区与Thoughtworks联合策划了本次技术沙龙,遵循“技术学习回归本质,区块链应用融入场景”这一观点, 邀请杨镇老师讲解以太坊黄皮书,同时邀请到ThoughtWorks 咨询师/软件开发工程师王瑞鹏老师分享区块链在房屋租赁中的应用。 虽然前些天的房屋租赁风波逐渐平息,但事件中暴露出的相关问题仍然存在,同时房屋租赁中还有类似于黑中介、涨房租等等一系列问题,在这个场景中,区块链能解决什么问题? 10月13日,本次活动在华贸商务楼联合创业办公社进行,点击“阅读原文”即可报名参与。 1 时间地点 主题:理论与实践|以太坊黄皮书解读+房屋租赁应用开发 时间 :10月13日13:30—17:00 地点 :北京朝阳区建国路89号华贸商务楼16号B1 联合创业办公社、一层入负一层(711便利商店旁,地铁大望路站F口) 2 分享嘉宾及主题 话题1

Performing a single switch in reactive-banana

荒凉一梦 提交于 2020-03-01 03:19:10
问题 I'm building a multi-modal editor using reactive-banana - and for the most part it's going perfect. To expand on my scenario, the editor is some mapping software, or you could think of it as a very simple vector graphics editor. It currently has two states - selection mode and polygon creation mode . In selection mode, the user is able to select previously created polygons with the right mouse button (which would in theory take you to a new selected mode ) or they can begin creating a new

How to know what are the full list of function availlable in an import?

拥有回忆 提交于 2020-02-29 17:44:08
问题 In Haskell if I import a module e.g. import Data.List How can I know what is the total method that Data.List made available ? In Prelude I can use completion like said here Is there a way to see the list of functions in a module, in GHCI?:: Prelude> :m +Data.List Prelude Data.List> Data.List.<PRESS TAB KEY HERE> But I want to get this in a list that be can manipulate, not in Prelude. This question is not about builtins how to know in Haskell the builtins functions?, (I mean by builtins

函数式编程

折月煮酒 提交于 2020-02-29 13:33:59
什么是 Type Class ? Type Class (类型类) 的概念来自 Haskell,表示一系列函数的集合,在概念上, Type Class 和面向对象领域的 泛型接口 比较类似。 由于 Haskell 是一门纯函数式编程语言,没有类和接口的概念,所以使用 Type Class 表达类似接口的概念。例如 Haskell 的 Ord 类型类在概念上和 Java 的 Comparable 非常类似。 在 Haskell 中,Type Class 使用 class 关键字定义: class BasicEq a where isEqual :: a -> a -> Bool isEqual x y = not (isNotEqual x y) isNotEqual :: a -> a -> Bool isNotEqual x y = not (isEqual x y) Type Class Instance 则使用 instance 关键字定义: instance BasicEq Bool where isEqual False False = True isEqual True True = True isEqual _ _ = False 只要定义了 Bool 类型的 Type Class Instance,我们就可以在任何地方使用 isEqual 方法比较 Bool

纯函数式编程的效率

房东的猫 提交于 2020-02-28 10:27:44
有谁知道纯功能编程而不是强制性编程(即允许副作用)发生时,最糟糕的渐近减速可能是什么? 从itowlson的评论中澄清 :是否存在最知名的非破坏性算法比最知名的破坏性算法渐近恶化的问题? #1楼 本文 声称, 联合查找算法 的已知纯功能实现都比它们发布的 算法 具有更差的渐进复杂度,后者具有纯功能接口,但内部使用可变数据。 其他答案声称永远没有任何区别,例如,纯功能代码的唯一“缺点”是它可以并行化,这一事实使您对功能编程社区在这些问题上的了解程度/客观性有所了解。 编辑: 下面的评论指出,对纯函数式编程的优缺点的偏颇的讨论可能不会来自“函数式编程社区”。 好点子。 也许我看到的倡导者只是在评论中说是“文盲”。 例如,我认为该 博客文章 是由可以说是功能编程社区代表的人撰写的,并且由于它是“懒惰评估的要点”列表,因此,它是提及任何缺点的好地方懒惰和纯函数式编程可能具有。 解雇以下人员是一个不错的选择(从技术上讲是正确的,但偏向于不搞笑): 如果严格函数在严格语言中具有O(f(n))复杂度,那么在懒惰语言中函数也具有O(f(n))复杂性。 为什么要担心? :) #2楼 我建议阅读 Haskell的性能 ,然后看一下功能语言与程序/ OO语言的 基准游戏 性能。 #3楼 根据 Pippenger [1996]的研究 ,当将纯功能的Lisp系统(具有严格的评估语义,而不是惰性的

Cannot enter multiline statements in GHCi [duplicate]

倾然丶 夕夏残阳落幕 提交于 2020-02-27 23:13:49
问题 This question already has answers here : Multi-line commands in GHCi (4 answers) Closed 6 years ago . let x=1 y=2 z=3 does not work in GHCi, forcing me to use let {x=1;y=2;y=3} instead. How can I fix this problem? 回答1: The documentation says: GHCi also has a multiline mode, enabled by :set +m, in which GHCi detects automatically when the current statement is unfinished and allows further lines to be added. A multi-line input is terminated with an empty line. The multiline mode makes GHCi

Cannot enter multiline statements in GHCi [duplicate]

纵然是瞬间 提交于 2020-02-27 23:13:46
问题 This question already has answers here : Multi-line commands in GHCi (4 answers) Closed 6 years ago . let x=1 y=2 z=3 does not work in GHCi, forcing me to use let {x=1;y=2;y=3} instead. How can I fix this problem? 回答1: The documentation says: GHCi also has a multiline mode, enabled by :set +m, in which GHCi detects automatically when the current statement is unfinished and allows further lines to be added. A multi-line input is terminated with an empty line. The multiline mode makes GHCi

Is there any working implementation of reverse mode automatic differentiation for Haskell?

假如想象 提交于 2020-02-26 12:03:07
问题 The closest-related implementation in Haskell I have seen is the forward mode at http://hackage.haskell.org/packages/archive/fad/1.0/doc/html/Numeric-FAD.html. The closest related related research appears to be reverse mode for another functional language related to Scheme at http://www.bcl.hamilton.ie/~qobi/stalingrad/. I see reverse mode in Haskell as kind of a holy grail for a lot of tasks, with the hopes that it could use Haskell's nested data parallelism to gain a nice speedup in heavy

如何从Unix上的文本文件中提取预定范围的行?

梦想与她 提交于 2020-02-26 03:25:47
我有一个~23000行的SQL转储包含几个数据库的数据。 我需要提取此文件的某个部分(即单个数据库的数据)并将其放在一个新文件中。 我知道我想要的数据的起始行和结束行号。 有没有人知道一个Unix命令(或一系列命令)从第16224和16482行之间的文件中提取所有行,然后将它们重定向到一个新文件? #1楼 我会用: awk 'FNR >= 16224 && FNR <= 16482' my_file > extracted.txt FNR包含从文件中读取的行的记录(行)编号。 #2楼 我编写了一个名为 splitter 的Haskell程序,它正是这样做的: 阅读我的发布博客文章 。 您可以按如下方式使用该程序: $ cat somefile | splitter 16224-16482 这就是它的全部内容。 您将需要Haskell来安装它。 只是: $ cabal install splitter 你完成了。 我希望你发现这个程序很有用。 #3楼 awk 还有另一种方法: awk 'NR==16224, NR==16482' file 如果文件很大,最好在读取最后一行后 exit 。 这样,它就不会不必要地读取以下行: awk 'NR==16224, NR==16482-1; NR==16482 {print; exit}' file #4楼 即使我们可以在命令行检查: cat

Why does this code work with Yesod.Persist's get404 but not getBy404?

天涯浪子 提交于 2020-02-25 05:53:27
问题 Let's say I have a table of dog names and breeds as follows: share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist| Dog name Text breed Text UniqueDog name |] I have the following routes: mkYesod "DogApp" [parseRoutes| / RootR GET /dog/name/#Text DogNameR GET /dog/id/#DogId DogIdR GET |] And I'm trying to create a page that returns the breed of the dog given it's name. I can do this with the Id in the URL via the getDogIdR route just fine: getDogIdR :: DogId -> Handler RepHtml