Skip to content

Commit b644409

Browse files
WIP
1 parent 0161991 commit b644409

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

backend/middle-1/haskell.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,31 @@ How can we bundle Pattern Synonyms with datatypes in export and import lists?
121121

122122
## Laziness
123123

124-
* How is value from evaluated thunk stored (are we allowed to avoid redundant reevaluations)?
124+
* How is a value in an evaluated thunk stored (are we allowed to avoid redundant reevaluations)?
125125
* Enumerate cases where thunk with ADT will be evaluated.
126-
* What is the irrefutable pattern and how does it work?
127-
* What does the `sprint` function do?
126+
* What is an irrefutable pattern and how does it work?
127+
* Where are patterns in Haskell irrefutable by default?
128+
* Which patterns are irrefutable:
129+
1. `f (Just a) = ...`
130+
1. `let (Just a) = ...`
131+
1. `where (Just a) = ...`
132+
1. `g (MyType a) = ...` where `MyType` is a `newtype` declaration.
133+
1. `g (MyType a) = ...` where `MyType` is a `data` declaration.
134+
1. `f a = ...`
135+
1. `f _ = ...`
136+
* When can irrefutable patterns be helpful? Hint: you may describe why
137+
[`Data.List.partition`](https://hackage.haskell.org/package/base-4.16.0.0/docs/src/Data.OldList.html#partition)
138+
uses them.
139+
* What does the `sprint` command do in `ghci`?
128140

129141
#### Resources
130142

131143
* [Laziness from What I Wish I Knew When Learning Haskell](http://dev.stephendiehl.com/hask/#laziness)
132144
* [The GHC Runtime System - Ch. 4 Laziness](http://ezyang.com/jfp-ghc-rts-draft.pdf)
145+
* Haskell 2010 Language Report:
146+
* See p. 3.17.2 Informal Semantics of Pattern Matching in [Pattern Matching](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17)
147+
* [Irrefutable Patterns in Let Expressions](https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-440003.12)
148+
* See p. 4.4.3.2 Pattern bindings in [Nested declarations](https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-800004.4)
133149

134150
## Exceptions
135151

0 commit comments

Comments
 (0)