在好例子网,分享、交流、成长!
您当前所在位置:首页Others 开发实例一般编程问题 → 《Haskell Design Patterns》

《Haskell Design Patterns》

一般编程问题

下载此实例
  • 开发语言:Others
  • 实例大小:1.02M
  • 下载次数:2
  • 浏览次数:19
  • 发布时间:2023-01-16
  • 实例类别:一般编程问题
  • 发 布 人:老刘
  • 文件格式:.pdf
  • 所需积分:0
 相关标签:

实例介绍

【实例简介】《Haskell Design Patterns》

【实例截图】

【核心代码】

Table of Contents
Preface v
Chapter 1: Functional Patterns – the Building Blocks 1
Higher-order functions 2
Functions as first-class citizens 2
Composing functions 3
Currying functions 3
Currying and composability 4
Decoupling with currying 5
Recursion 5
Non-tail recursion 5
Tail recursion 6
Folding abstracts recursion 6
Types, pattern matching, and polymorphism 7
Algebraic types and pattern matching 7
Recursive types 8
Polymorphism 8
Parametric polymorphism 8
Ad-hoc polymorphism 9
Functions, types, and patterns 13
The strategy pattern 14
The template pattern 14
The iterator pattern 15
Decoupling behavior and modularizing code 15
Lazy evaluation 15
Streams 16
Modeling change with streams 17
Lazy evil 18
Monads 18
Composing monads and structuring programs 20
Summary 21
Table of Contents
[ ii ]
Chapter 2: Patterns for I/O 23
I/O as a first class citizen 24
I/O as a functor, applicative, and monad 25
Imperative I/O 25
Lazy I/O 28
The problems with lazy I/O 33
Resource management with bracket 34
Iteratee I/O 36
Iteratee 37
Enumerator 39
Generalized iteratees, enumerators, and enumeratees 40
The iteratee I/O libraries 41
Comparing the three styles of I/O 42
Summary 42
Chapter 3: Patterns of Composition 43
Functor 43
Applicative functor 45
Monad 47
Monad as functor 49
Monad as applicative 50
Sequencing actions with monad and applicative 51
Monads and the bind chain 51
Composing with monads 53
Monad transformers 53
IO in monad stacks 57
Sequence of stack composition 58
Arrows 59
Implementing an arrow 60
Arrow operators 61
Kleisli arrows and monad arrows 63
Why arrows? 64
Summary 65
Chapter 4: Patterns of Folding and Traversing 67
Folding over lists 68
Folding with monadic functions 68
Folding with monoids 69
Foldable 71
Mapping over lists 74
Traversable 75
A Traversable Tree 76
Table of Contents
[ iii ]
The traversal and the Iterator pattern 77
Modernizing Haskell 98 78
Lenses 79
Deriving Lens 79
Writing a Lens 81
Composable getters and setters 82
Lens Traversal 83
Lens.Fold 84
The Lens library 84
Summary 85
Chapter 5: Patterns of Type Abstraction 87
Abstracting function types: RankNTypes 88
Abstracting datatypes 89
Universal quantification 89
Existential quantification and abstract datatypes 90
Phantom types 91
Generalized algebraic datatypes 94
Typecase pattern 95
Dynamic types 96
Heterogeneous lists 98
Abstracting type-classes 99
Multiparameter type-classes 99
Functional dependencies 100
Summary 101
Chapter 6: Patterns of Generic Programming 103
Patterns of generic programming 104
Patterns 1 and 2 – functions 104
Pattern 3 – polymorphic types and functions 104
Pattern 4 – type-class polymorphism 104
Pattern 5 – meta-programming 105
The Derivable type-classes 105
Generalized newtype deriving 105
Pattern 6 – type laws 105
Pattern 7 – datatype generic programming 106
The sum of products style 107
The sum of products type representation 108
Translating between the type and representation 109
Writing a datatype-generic function 109
Adding a new datatype 112
GHC.Generics – a generic deriving mechanism 112
Origami programming 113
Tying the recursive knot 113
Table of Contents
[ iv ]
The generic map 114
The generic fold 115
main = print $ gfold addL aListF 116
Generic unfold and fold 116
Origami design patterns 117
Scrap your boilerplate 118
The type-safe cast with typeable 119
Type-safe function application 120
The shallow traversal and the data type-class 121
Typeable and data 123
Scrap your boilerplate 123
Summary 124
Chapter 7: Patterns of Kind Abstraction 125
Higher-order kinds 126
Higher-kinded polymorphism 127
Associated type synonyms 128
Using functional dependencies 128
Associated type synonyms 129
Associated types versus functional dependencies 130
Type (synonym) families 130
Data families 132
Kind polymorphism 132
The PolyKinds language extension 134
Type promotion 135
Promoting types to kinds 137
Type-level programming 138
Promoting term-level programs to type-level 139
Closed type families 139
The history of type-level programming in Haskell 140
Type-level and generic programming 140
Dependently-typed programming 141
Haskell and dependently-typed programming 142
Summary 143
Epilogue 143
Index 145

标签:

实例下载地址

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警