File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -223,15 +223,27 @@ day4part2 input = do
223
223
224
224
By this time, I found some other posts about people using Haskell for AoC, and
225
225
found about the ` Comonad ` class, implemented by ` Store ` . They used the
226
- properties of ` Comonad ` , which are the following:
226
+ properties of ` Comonad ` , which are the following (simplified).
227
227
228
228
``` haskell
229
+ class Monad m where
230
+ return :: a -> m a
231
+ (>>=) :: m a -> (a -> m b ) -> m b
229
232
233
+ class Comonad w where
234
+ extract :: w a -> a
235
+ extend :: (w a -> b ) -> w a -> w b
230
236
```
231
237
232
- Having a ` Store ` of points allows you to also define a function from Store of
233
- points to check if there is a cross, and the extend this function to get a Store
234
- of checks. Neat!
238
+ Similarly to `Monad `, but reverse , `extend` takes a function of a wrapped value
239
+ to a value (the opposite of bind), and `extract` is the opposite operation of
240
+ `return` .
241
+
242
+ Having a `Store ` that implements `Comonads `, allows you to:
243
+
244
+ - Extract the central value of the Store (which can be sought).
245
+ - Apply a function that takes a `Store ` of points to check if it is a cross, and
246
+ then extend it to all possible values.
235
247
236
248
## Day 5: More parsing
237
249
You can’t perform that action at this time.
0 commit comments