type Choice a = [a]
choose :: [a] -> Choice a
choose xs = xs
Monads in 15 minutes: Backtracking and Maybe - 0 views
-
-
Because Haskell doesn’t compute answers until we ask for them, we get the actual backtracking for free!
-
The missing function is almost too trivial to mention: Given a single value of type a, we need a convenient way to construct a value of type Choice a:
- ...5 more annotations...
jaspervdj - Maybe, null, and boilerplate code - 0 views
-
A first goal they serve is as "unassigned variables". I will not cover that here, instead I will focus on another use: abnormal return values.
-
So, null is some sort of "Not found" error here. But wait - they could have used an Exception here!
-
We see a similar behavior here: when the object is found, we get a Just a, and when it is not found, we get Nothing - comparable to a null pointer.
- ...5 more annotations...
1 - 3 of 3
Showing 20▼ items per page