2017-08-30 08:42:46 +03:00
|
|
|
Use of lenses and classy `mtl` will be left to supplemental material. It would
|
|
|
|
be nice to be able to use it lenses more but the additional explanation required
|
2017-08-24 09:06:48 +03:00
|
|
|
might be a bit much and not very predictable ?
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
### Further lessons
|
2017-08-24 09:06:48 +03:00
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - Death to Strings
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
|
|
|
Start up and Servant introduction.
|
|
|
|
|
|
|
|
* Use Scotty/Warp for the "hello, world" application.
|
|
|
|
* Explain that we're using strings for routes and this is bad(TM).
|
|
|
|
* Move to Servant, explain why, show type driven dev to explain routes->function relationship.
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - Would you like to play a game?
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
2017-09-05 08:53:21 +03:00
|
|
|
Introduce handling input/output also pre-empt the inclusion of persistent storage.
|
2017-08-24 09:06:48 +03:00
|
|
|
|
|
|
|
* Add rock-paper-scissors data type. (Don't create Enc/Dec instances yet)
|
|
|
|
* Add route to accept an RPS move that always plays paper against the user.
|
|
|
|
* Go over what the errors from Servant & GHC are telling us.
|
|
|
|
* Add the required instances.
|
|
|
|
* Change the function up so that it randomly selects a move, evaluates victory/defeat.
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - Type safe tantrums
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
|
|
|
Introduce error handling by breaking REST rules by having our application throw
|
|
|
|
an error when it loses at Rock-Paper-Scissors.
|
|
|
|
|
|
|
|
* Change RPS function to throw an error on defeat, creating required error data types.
|
|
|
|
* Discuss the errors that appear RE return values and making Servant respond appropriately.
|
|
|
|
* Introduce `ExceptT`, change the `ReaderT` from earlier to what we want it to be.
|
|
|
|
* More discussion to be had here regarding the ordering of transformer stacks.
|
|
|
|
* Discuss the errors that appear. Work through fixing these with type-holes in the Natural Transform.
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - Except when exceptionally excepted
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
2017-09-05 08:53:21 +03:00
|
|
|
Handling, catching, and re-throwing exceptions. Motivate errors as values over exceptions.
|
2017-08-24 09:06:48 +03:00
|
|
|
|
|
|
|
* Possible ways postgresql-simple can fail on us, note that the types provide no information
|
|
|
|
* Introduce exception handling with `catching` and `handling` to our error values.
|
|
|
|
* Generalise our current DB querying technique so that we take a query and
|
|
|
|
handle some exceptional cases.
|
|
|
|
* Discuss the relevance of handling these errors:
|
|
|
|
* Shouldn't they just come up in testing?
|
|
|
|
* I'm sure there are other points here, some Haskell applications are built
|
|
|
|
not to care about these sorts of errors.
|
2017-09-05 08:53:21 +03:00
|
|
|
|
2017-08-24 09:06:48 +03:00
|
|
|
* Discuss how you might implement logging ? Leave as exercise.
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - BOSS FIGHT - A
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
2017-09-05 08:53:21 +03:00
|
|
|
Replace the DB layer with something better:
|
2017-08-24 09:06:48 +03:00
|
|
|
- [Selda](https://selda.link/)
|
|
|
|
- [Tisch](https://github.com/k0001/tisch)
|
|
|
|
- [Opaleye](https://hackage.haskell.org/package/opaleye)
|
|
|
|
- [Groundhog](https://github.com/lykahb/groundhog)
|
|
|
|
|
|
|
|
These packages will force a lot of other things to be picked up at the same
|
|
|
|
time, to varying degrees:
|
2017-09-05 08:53:21 +03:00
|
|
|
- Selda : Type level lists, type operators, data structures as tuples initially.
|
|
|
|
- Tisch : Type level HLists, overloaded labels, type families, familiarity with Opaleye.
|
|
|
|
- Opaleye : Arrows, full polymorphic records.
|
|
|
|
- Groundhog : Alien data type definitions using their Template Haskell DSL, is
|
2017-08-24 09:06:48 +03:00
|
|
|
an ORM more than a type safe SQL package (if that makes sense).
|
2017-09-05 08:53:21 +03:00
|
|
|
|
2017-08-24 09:06:48 +03:00
|
|
|
All packages use generics of some description, not sure how much air time they
|
|
|
|
need? Passing mention and throw some links around, move on.
|
|
|
|
|
2017-08-30 08:42:46 +03:00
|
|
|
N - BOSS FIGHT - B
|
2017-08-24 09:06:48 +03:00
|
|
|
---
|
|
|
|
Integration of 'classy mtl' style application design.
|
|
|
|
|
|
|
|
* Briefly explain the problem with using a transformer stack or newtype'd stack
|
|
|
|
like we have.
|
|
|
|
* Concrete types
|
|
|
|
* Cannot generalise easily to abstract out larger moving parts
|
|
|
|
* Discuss what we want is just constraints, PARAMETRICITY driven development!!
|
|
|
|
* Build intuition for `AsFoo` & `HasFoo`
|
|
|
|
* `mtl` classes are a start, but how do we make this easier?
|
|
|
|
* Describe `CanFoo` and introduce `ConstraintKinds`
|
2018-01-22 04:40:11 +03:00
|
|
|
|
|
|
|
## Suggestions
|
|
|
|
|
|
|
|
* Lens
|
|
|
|
* Mocking / Free
|
|
|
|
* Dealing with callbacks (more info needed)
|
|
|
|
* Streaming / Iteratees (safe resource handling)
|
|
|
|
* ST / Safe Mutation techniques
|
|
|
|
* Classy MTL
|
|
|
|
* Generic / Meta programming
|
|
|
|
* Daemons
|
|
|
|
* Ermagerd reel librees!
|
|
|
|
* Concurrency packages/techniques (book recommendation) - STM
|
|
|
|
* Property Based Testing (Hedgehog, advanced testing)
|
|
|
|
* Stats
|