summaryrefslogtreecommitdiffstats
path: root/content/zettel/3c3c1.md
diff options
context:
space:
mode:
Diffstat (limited to 'content/zettel/3c3c1.md')
-rw-r--r--content/zettel/3c3c1.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/content/zettel/3c3c1.md b/content/zettel/3c3c1.md
new file mode 100644
index 0000000..05fb1fa
--- /dev/null
+++ b/content/zettel/3c3c1.md
@@ -0,0 +1,20 @@
++++
+title = "Using the State monad for hash consing"
+author = "Yann Herklotz"
+tags = []
+categories = []
+backlinks = ["3c3c"]
+forwardlinks = ["3c3c2"]
+zettelid = "3c3c1"
++++
+
+One example is to use the State monad to remember inputs and their
+results. However, there are many down sides to doing it this way. First,
+this means that every function that should be memoized needs to use a
+monadic type. Therefore `A -> B` is converted to `A -> M B`, where `M`
+is the State monad.
+
+This then means that every other call site needs to be changed to work
+in the State monad, which is quite difficult, and makes it even harder
+to reason about the code. This is because it is a deep embedding of
+memoization in Coq.