├── OUTLINE.md ├── book.graphml ├── book ├── acccumulating-caches.md ├── adts.md ├── algebraic-properties.md ├── alternatives.md ├── antipatterns.md ├── applications-want-to-be-libraries.md ├── applicatives.md ├── asymptotic-improvement.md ├── bend-it-to-fit-the-abstraction.md ├── code-reifies-understanding.md ├── codensity.md ├── combinator-libraries.md ├── common-iterations.md ├── common-typeclasses.md ├── common-types.md ├── comonads.md ├── compose-type.md ├── composition-of-correctness.md ├── composition-of-functions.md ├── composition-of-implementations.md ├── composition-of-understanding.md ├── composition.md ├── composition2.md ├── computing-is-not-about-computers.md ├── concepts.md ├── coproducts.md ├── copy-on-write.md ├── correctness.md ├── cps.md ├── custom-control-flow.md ├── data-dependency.md ├── denotations.md ├── derive-performance-from-the-problem.md ├── desiderata.md ├── diagram-envelopes.md ├── dlists.md ├── dynamic-programming.md ├── effects.md ├── either.md ├── empathy.md ├── endos.md ├── existentializing.md ├── existentials-as-arguments.md ├── final-encodings.md ├── finger-trees.md ├── flexibility.md ├── foldmaps.md ├── folds.md ├── forall.md ├── function-monoids.md ├── function-types.md ├── functions.md ├── functors.md ├── gadts.md ├── higher-order-functions.md ├── i1.md ├── if-it-compiles-it-works.md ├── illegal-states-are-unrepresentable.md ├── infinite-data-structures.md ├── initial-encodings.md ├── introduction-and-elimination.md ├── isomorphisms.md ├── laws.md ├── lists.md ├── maps.md ├── maybe.md ├── memoization.md ├── modeling-with-types.md ├── monads-are-overused.md ├── monads.md ├── monoids.md ├── mu.md ├── newtypes-over-aliases.md ├── nonregular-recursion.md ├── nu.md ├── only-local-coherence.md ├── open-world-assumption.md ├── parallel-over-sequential.md ├── parsers.md ├── partial-functions.md ├── philosophy.md ├── pointwise-monoid.md ├── precomposition.md ├── problems.md ├── products.md ├── property-tests.md ├── pure-over-effectful.md ├── purity.md ├── quantifiers.md ├── recursion-schemes.md ├── representable-functors.md ├── reusable-vocabulary.md ├── selectives.md ├── semilattices.md ├── separate-interface-and-implementation.md ├── sharing.md ├── simplicity.md ├── smart-constructors.md ├── structural-diffing.md ├── structural-problems.md ├── structural-programming.md ├── syntax-and-semantics.md ├── testing.md ├── the-best-abstractions-already-exist.md ├── theory.md ├── there-and-back-again.md ├── thinking-about-performance-gets-in-the-way.md ├── tools.md ├── totality.md ├── trampolining.md ├── traversals.md ├── tricks.md ├── type-variables.md ├── types-and-values.md ├── types.md ├── u1.md ├── understanding-before-implementation.md ├── unfolds.md ├── unsafe-coerce-the-existential.md ├── v1.md ├── validation.md ├── vs-union-types.md ├── well-typed.md ├── what-not-how.md └── yoneda-embeddings.md ├── enstructer ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── Setup.hs ├── app │ └── Main.hs ├── enstructer.cabal ├── package.yaml ├── src │ └── Lib.hs ├── stack.yaml ├── stack.yaml.lock └── test │ └── Spec.hs ├── outline2.gml ├── outline2.graphml ├── structure.graphml ├── test.dot └── test.pdf /OUTLINE.md: -------------------------------------------------------------------------------- 1 | - Why functional programming matters? It's math. 2 | - Why does math work? 3 | - It mirrors our mind. 4 | - Even if you don't know all the words that mathematicians use, you will be 5 | surprised if the problem domain you're working in isn't associative. 6 | - The point is not therefore that FP is better because it's more 7 | mathematical, but because reasoning about it is much more similar to how 8 | our minds work. 9 | - That is not to say that this is actually how our brains are IMPLEMENTED. 10 | - Feasibility 11 | - Do you have the resources/know-how/budget/whatever to get this feature 12 | done? If yes, great. 13 | - If no, you will need to get better at politics or at corner cutting. 14 | Cut those corners which effect the following principles the least. 15 | - The Principles 16 | - Correctness 17 | - Does the program do what it is supposed to? Do you know what it is 18 | supposed to do? How can it do that if you don't know what it is 19 | supposed to do? 20 | - In general, correctness means having no bugs WRT a specification. If 21 | you don't have a specification you can't possibly be correct. 22 | - Correctness also applies to the mental model that people build about 23 | your software. If the implementation doesn't correspond to the mental 24 | model, it is also not correct. 25 | - Because people don't code against your system, they code against 26 | their mental model of your system. 27 | - This means you can't "document away" bugs. Weird edge cases are 28 | bugs. 29 | - Encode invariants in the type system. Make illegal states 30 | unrepresentable. 31 | - Flexibility 32 | - The specification will always change. The goals will always move. 33 | - How do you ensure what you've built is capable of handling those 34 | moving goals? 35 | - When you need to cut a corner, how do you do it in such a way that you 36 | don't paint yourself into a corner? How do you make sure the cut 37 | corner wasn't important? How do you fill it in later? 38 | - DRY. The more cruft you have the less flexible you are to change. 39 | - Use the right abstractions/common vocabularies, such that changes are 40 | as minor as possible. 41 | - Empathy 42 | - Document. Not just for your coworkers, but for yourself in the future. 43 | - Don't learn on the job. 44 | - Don't do something complicated when a simple solution would work, 45 | unless you can appeal to one of the other principles. 46 | - Eliminate the possibility for easy-to-make errors whenever possible. 47 | Encode business logic in the type system. 48 | - Weigh the complexity of a change and ensure it's at the pareto 49 | frontier of the solution space. 50 | - Concave/convex problems. 51 | - Everything stems from these things. 52 | - Do it correctly, unless its infeasible. In which case, be flexible about 53 | doing it as not-wrong as possible. When deciding between two options, 54 | always pick the one that maximizes empathy. 55 | - Correctness/Flexibility are often accomplished simultaneously. 56 | - Applications are never the right thing to think about. Instead think about 57 | libraries. 58 | - Writing a library forces you to focus on the general problem, which 59 | increases the surface area of problems you are considering. 60 | - Writing a library means you can compose it together differently in order 61 | to solve evolving application demands. 62 | - Having a general purpose library means people can solve problems you can't 63 | imagine. 64 | - When you add empathy to the list, it forces you to think about the API 65 | surface of that library, and make it as pleasant to use as possible. 66 | - ^ That is to say, libraries are the only solution to the above system of 67 | equations. 68 | - Structuring applications 69 | - Applications should always be the barest wrapper around a library as 70 | possible. 71 | - Applications may load configuration and connect some UI elements to 72 | library code. And nothing else. 73 | - The meat of your code should be general purpose library code, some of 74 | which gets composed together to make the application. But the library 75 | comes first and is significantly more capable than the application ever 76 | provides. 77 | - Applications are hard to test, with all the UI stuff you need to operate 78 | on and automate. Libraries are easy---just make the calls and check the 79 | output. 80 | - Structuring libraries 81 | - Libraries need not correspond to distinct compilation packages, but 82 | instead a strongly connected cluster of modules which exist to model some 83 | particular domain. 84 | - A software system is likely made up of many subsystems, each of which is 85 | modeled by a library. 86 | - If those independent subsystems need to interact, that too should be a 87 | library made up of components of the independent systems. 88 | - Think more about "what" than "how" 89 | - WHAT am I trying to build? WHAT things make sense to model? WHAT 90 | invariants should hold here? 91 | - These are the crucial questions. They are the specification behind the 92 | "how do I make that happen?" 93 | - Focus on getting the "what" right; this gives you flexibility in the "how". 94 | - Most programming is all about how! But how to what? It's unclear! You have 95 | to build up a mental model of the what implicitly from the how. 96 | - A library models a consistent and connected set of "what"s. 97 | - Made up of TYPES, which give us nouns that we can string functions 98 | between. 99 | - And combinators, which create and transform values of TYPES into other 100 | TYPES. 101 | - Notice already we have given a more general solution than what is standard 102 | in the literature. The much heralded MVC pattern is a special case of the 103 | separation of application (view) from library (model and controller), 104 | where the model is the types and the controllers are (often poorly 105 | modeled) functions. 106 | - What are the properties of a good library? 107 | - It has a meaning. This is the specification/what from which all 108 | correctness comes downstream. This meaning gives rise to a mental model. 109 | - It solves the general problem. It is more useful than the original use 110 | case. 111 | - It is an abstract solution to the problem. Existing constraints exist in 112 | the problem domain, not the implementation. 113 | - It is impossible to use wrong. Every possible well-typed combination of 114 | functions is meaningful. Meaningless expressions are not well-typed. 115 | -------------------------------------------------------------------------------- /book/acccumulating-caches.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: acccumulating-caches 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - monoids 7 | - tricks 8 | smaller: 9 | - diagram-envelopes 10 | - finger-trees 11 | see-also: [] 12 | name: "acccumulating-caches" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/adts.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: adts 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "adts" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/algebraic-properties.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: algebraic-properties 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - laws 7 | - property-tests 8 | smaller: 9 | - derive-performance-from-the-problem 10 | see-also: [] 11 | name: "algebraic-properties" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/alternatives.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: alternatives 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | smaller: 8 | - either 9 | - lists 10 | - maybe 11 | see-also: [] 12 | name: "alternatives" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/antipatterns.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: antipatterns 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - existentials-as-arguments 8 | - monads-are-overused 9 | - partial-functions 10 | - unsafe-coerce-the-existential 11 | - vs-union-types 12 | see-also: [] 13 | name: "antipatterns" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/applications-want-to-be-libraries.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: applications-want-to-be-libraries 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: 8 | - monads-are-overused 9 | see-also: [] 10 | name: "applications-want-to-be-libraries" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/applicatives.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: applicatives 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - compose-type 8 | - effects 9 | - parallel-over-sequential 10 | - traversals 11 | smaller: 12 | - validation 13 | see-also: [] 14 | name: "applicatives" 15 | teaser: "" 16 | --- 17 | 18 | 19 | ...bigger context... 20 | 21 | --- 22 | 23 | TODO(sandy): main body 24 | 25 | --- 26 | 27 | ...smaller context... 28 | -------------------------------------------------------------------------------- /book/asymptotic-improvement.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: asymptotic-improvement 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - tricks 7 | smaller: 8 | - yoneda-embeddings 9 | see-also: [] 10 | name: "asymptotic-improvement" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/bend-it-to-fit-the-abstraction.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: bend-it-to-fit-the-abstraction 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - reusable-vocabulary 7 | smaller: [] 8 | see-also: [] 9 | name: "bend-it-to-fit-the-abstraction" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/code-reifies-understanding.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: code-reifies-understanding 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: [] 8 | see-also: [] 9 | name: "code-reifies-understanding" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/codensity.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: codensity 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - initial-encodings 7 | - yoneda-embeddings 8 | smaller: [] 9 | see-also: [] 10 | name: "codensity" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/combinator-libraries.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: combinator-libraries 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition-of-correctness 7 | - composition-of-implementations 8 | - composition-of-understanding 9 | - modeling-with-types 10 | - tools 11 | smaller: 12 | - parsers 13 | see-also: [] 14 | name: "Combinator Libraries" 15 | teaser: "" 16 | --- 17 | 18 | 19 | ...bigger context... 20 | 21 | --- 22 | 23 | Make a list of each salient concept in your problem domain. These are good 24 | candidates for the types in your library. Without fail, this list will be 25 | *wrong,* but it's a good starting point. We'll use the audio processing library 26 | as our on-going example for this section. Thus, let's lay out our candidate types: 27 | 28 | ```haskell 29 | data AudioFile 30 | data Waveform 31 | data Frequency 32 | data Pitch 33 | data Time 34 | ``` 35 | 36 | Next, make a list of every interaction you can think of that exists between the 37 | type candidates enumerated above. Pay close attention to the "obvious" 38 | interactions---that is to say, the things you're aware that you'd like your 39 | library to be able to do. In our audio processing example, this might be: 40 | 41 | * extract the channels of an audio file as waveforms 42 | * sample a waveform at a particular time 43 | * combine two waveforms together 44 | * build a waveform out of a constant frequency 45 | * build a waveform out of a value changing over time 46 | * shift a waveform in time 47 | * mute a section of a waveform 48 | * add an echo to a waveform 49 | * export waveforms as the channels of an audio file 50 | 51 | Notice that some of these operations are between several candidate types (such 52 | as extracting the channels of an audio file as waveforms), while others are 53 | only over a single candidate (such as shifting a waveform in time.) Even if an 54 | interaction aren't obviously necessary for whatever you originally set out to 55 | build, if it's meaningful, write it down. As a general principle, strive 56 | towards having a few interactions that introduce concepts, and several that 57 | eliminate them ([introduction-and-elimination]()). In particular, aim to have 58 | at least one way of producing each domain object. 59 | 60 | This stage is to come up with examples of you'd like to be able to do with your 61 | library. Lay each desired interaction out as a function: 62 | 63 | ```haskell 64 | extractChannels :: AudioFile -> List Waveform 65 | sampleWF :: Waveform -> Time -> Frequency 66 | combineWF :: Waveform -> Waveform -> Waveform 67 | signal :: (Time -> Pitch) -> Waveform 68 | delay :: Waveform -> Time -> Waveform 69 | silence :: Time -> Time -> Waveform -> Waveform 70 | echo :: Waveform -> Waveform 71 | exportAudio :: List Waveform -> AudioFile 72 | ``` 73 | 74 | Like the set of types we originally came up with, this list probably too is 75 | wrong, and certainly is incomplete. But all we're looking for is a starting 76 | point. 77 | 78 | Often, these identified functions will appear as groups of related 79 | functionality. One particularly illuminating grouping is 80 | [there-and-back-again](), in which we look for functions that appear to be 81 | inverses of one another. Above, there are two such groups: 82 | 83 | 1. ```haskell 84 | extractChannels :: AudioFile -> List Waveform 85 | exportAudio :: List Waveform -> AudioFile 86 | ``` 87 | 2. ```haskell 88 | sampleWF :: Waveform -> Time -> Frequency 89 | signal :: (Time -> Pitch) -> Waveform 90 | ``` 91 | 92 | Spotting this second group requires a little sluething---we must recall that 93 | the function arrow associates to the right ([function-types]()), and identify 94 | that there isn't much in the way of our listed interactions that differentiates 95 | between `Pitch` and `Frequency`. 96 | 97 | [isomorphisms]() like these, especially when one side is expressed in terms of 98 | types that have obvious, real world interpretations---such as `Time` and 99 | `Frequency`---are exceptionally good candidates for the [denotations]() of your 100 | combinator library. 101 | 102 | Another good way of grouping functions is by looking for [endos]()---functions 103 | that consume and produce a value of the same type. This gives us a third group: 104 | 105 | 3. ```haskell 106 | combineWF :: Waveform -> Waveform -> Waveform 107 | silence :: Time -> Time -> Waveform -> Waveform 108 | echo :: Waveform -> Waveform 109 | ``` 110 | 111 | The express goal is now to generalize as much of the interface as you can. 112 | Taking the denotation of `Waveform` to be `Time -> Frequency`, we can ask 113 | ourselves whether it is meaningful to parameterize either side of the function 114 | arrow. While functions out of some general type `a` into `Frequency` are 115 | potentially psychedelically interesting, it's unclear whether this is a good 116 | generalization. 117 | 118 | Instead, consider functions out of timem *into* some general type `a`. These are 119 | "signals" that vary over time, of which `Frequency` is just a special case. 120 | Therefore we can try: 121 | 122 | ```haskell 123 | data Signal a 124 | type Waveform = Signal Frequency 125 | ``` 126 | 127 | Consider each function from group 3 generalized against this new `Signal` type, 128 | instead of being directly over `Waveform`s. None of them make much sense as 129 | written, but with minor changes we can fix each. First, let's look at `combineWF`: 130 | 131 | ```haskell 132 | combineWF :: forall a. Signal a -> Signal a -> Signal a 133 | ``` 134 | 135 | Due to the [forall]() quantifier on this type, we have no means of combining the 136 | `a` value at corresponding moments in time. Thus, we must introduce a combining 137 | operation: 138 | 139 | ```haskell 140 | combineWF :: forall a. (a -> a -> a) -> Signal a -> Signal a -> Signal a 141 | ``` 142 | 143 | Having made this transformation, there is now no reason that we need only 144 | a single abstract type. Thus, generalize the type further: 145 | 146 | ```haskell 147 | combineWF :: forall a b c. (a -> b -> c) -> Signal a -> Signal b -> Signal c 148 | ``` 149 | 150 | The type of `combineWF` is now of a familiar shape ([applicatives]()), and due 151 | to [the-best-abstraction-already-exists](), we ought to look for more 152 | applicative structure in `Signal`. Does it admit an applicative unit? 153 | 154 | ```haskell 155 | constantS :: forall a. a -> Signal a 156 | ``` 157 | 158 | This is certainly tenable, `constantS` would produce a `Signal` that never 159 | changes. Therefore, it seems likely that `Signal` has an applicative structure, 160 | and thus we ought to look also for a function structure: 161 | 162 | ```haskell 163 | mapS :: (a -> b) -> Signal a -> Signal b 164 | ``` 165 | 166 | Again, this is a very reasonable addition, in that we'd like to post-compose the 167 | output of a function-over-time. The applicative laws state that we can always 168 | give functor structure whenever we have applicative structure (see 169 | [applicatives]()), but even if this were not true, functors can always be 170 | created [initial-encodings](freely) via [yoneda](). 171 | 172 | Due to [the-best-abstraction-already-exists](), you will often discover that 173 | most of your problem domain reduces to known abstractions. Given the new 174 | applicative structure for `Signal`, we can cast our vengeful gaze on `silence`: 175 | 176 | ```haskell 177 | silence :: forall a. Time -> Time -> Signal a -> Signal a 178 | ``` 179 | 180 | The loosely-intended semantics here were to "blank out" the signal between the 181 | given times, but again, the universally-quanitifed nature of the new signature 182 | doesn't allow us to do so. Instead we could try taking a parameter representing 183 | silence: 184 | 185 | ```haskell 186 | silence :: forall a. a -> Time -> Time -> Signal a -> Signal a 187 | ``` 188 | 189 | but such an implementation would therefore be equivalent to: 190 | 191 | ```haskell 192 | silence silent start end s = 193 | signal (\t -> 194 | if t >= start && t < end 195 | then silent 196 | else sampleSF s t 197 | ) 198 | ``` 199 | 200 | which means we may provide `silence` in our library if we'd like, but it does 201 | not need to be a first-class primitive. 202 | 203 | 204 | --- 205 | 206 | ...smaller context... 207 | -------------------------------------------------------------------------------- /book/common-iterations.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: common-iterations 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - the-best-abstractions-already-exist 7 | smaller: 8 | - foldmaps 9 | - maps 10 | - recursion-schemes 11 | - traversals 12 | see-also: [] 13 | name: "common-iterations" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/common-typeclasses.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: common-typeclasses 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - reusable-vocabulary 7 | - the-best-abstractions-already-exist 8 | - theory 9 | smaller: 10 | - alternatives 11 | - applicatives 12 | - comonads 13 | - functors 14 | - monads 15 | - monoids 16 | - selectives 17 | - semilattices 18 | see-also: [] 19 | name: "common-typeclasses" 20 | teaser: "" 21 | --- 22 | 23 | 24 | ...bigger context... 25 | 26 | --- 27 | 28 | TODO(sandy): main body 29 | 30 | --- 31 | 32 | ...smaller context... 33 | -------------------------------------------------------------------------------- /book/common-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: common-types 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: 8 | - either 9 | - lists 10 | - maybe 11 | see-also: [] 12 | name: "common-types" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/comonads.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: comonads 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - infinite-data-structures 8 | smaller: [] 9 | see-also: [] 10 | name: "comonads" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/compose-type.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: compose-type 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: 8 | - applicatives 9 | - functors 10 | - selectives 11 | see-also: [] 12 | name: "compose-type" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/composition-of-correctness.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition-of-correctness 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition 7 | - correctness 8 | smaller: 9 | - combinator-libraries 10 | see-also: [] 11 | name: "composition-of-correctness" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/composition-of-functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition-of-functions 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition 7 | - functions 8 | smaller: 9 | - trampolining 10 | see-also: [] 11 | name: "composition-of-functions" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/composition-of-implementations.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition-of-implementations 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition 7 | smaller: 8 | - combinator-libraries 9 | see-also: [] 10 | name: "composition-of-implementations" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/composition-of-understanding.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition-of-understanding 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition 7 | - denotations 8 | smaller: 9 | - combinator-libraries 10 | see-also: [] 11 | name: "composition-of-understanding" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/composition.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: 8 | - composition-of-correctness 9 | - composition-of-functions 10 | - composition-of-implementations 11 | - composition-of-understanding 12 | - types 13 | see-also: [] 14 | name: "Composition" 15 | teaser: "" 16 | --- 17 | 18 | 19 | ...in the [philosophy]() of functional programming, one pattern stands above 20 | all---the means by which we create something complex out of simpler components. 21 | 22 | --- 23 | 24 | **Much like a beautiful piece of music, software too is composed---according to 25 | a rigid set of rules and constraints, which often are "felt" more than they are 26 | understood.** 27 | 28 | 29 | Composition is the idea that we can combine smaller components into larger 30 | systems and "get away with it." That is to say, that the larger system preserves 31 | some desired behavior that each of its components originally possessed. 32 | Composition is the most powerful tool in all formalized engineering practices 33 | and scientific disciplines, as it's what allows us to reason about small pieces 34 | but build systems too large for any one human to understand. 35 | 36 | The notion of composition is a slippery one, not at all aided by the many subtle 37 | shades of overloaded meaning it carries. In programming, we can compose 38 | solutions to subproblems into larger solutions (as in [dynamic-programming]()). 39 | Familiarly, algorithms can be composed sequentially (do this, and then do that). 40 | But they can also be composed "inside-out," when an algorithm isn't fully 41 | specified in its behavior---for example, discussions of hash map implementations 42 | often leaves unsaid what should happen when two keys produce the same hash. 43 | Values at runtime are often built up of smaller values, in a dizzying number of 44 | possibilities. 45 | 46 | Outside the discipline of programming, it is composition that allows physicists 47 | to understand magnetic fields by integrating the interactions of trillions of 48 | simple point-charges. It is composition by which books are made up of chapters, 49 | comprised of paragraphs, consisting of sentences, themselves built out of 50 | words. The meaning of the book arises through the interaction of the meaning of 51 | the words. Perhaps the metaphor is a bit loose, in that surely some of the 52 | meaning of a book comes from its historical context, but let us not dwell too 53 | much on this point. 54 | 55 | Composition is the basis of reductionism, which to date is the most successful 56 | principle ever devised by humans. It is reductionism by which we make sense of 57 | the world in the small, and extrapolate that understanding to the large. It is 58 | the basis of philosophy, mathematics, logic, and science, themselves all 59 | exceptionally successful human endeavors. 60 | 61 | One wonders why exactly philosophy, mathematics, logic, and science have been 62 | so "unreasonably effective" in helping us understand the world we live in. To 63 | me, the only coherent answer is that these fields are all compositional. Small 64 | pieces can be understood and glued together to form bigger pictures, which 65 | themselves can be understood only in terms of their constituent parts. The 66 | human brain, as remarkable as it is, isn't a particularly capable device. They 67 | run at roughly 100Hz, and have enough "RAM" to keep only seven things in mind 68 | simultaneously. These are extremely tight constraints, especially when tackling 69 | big systems. 70 | 71 | Our only recourse, therefore, is to layer abstractions upon one another, 72 | minding our way to the heavens. This is the basis and origin of composition. 73 | And if we are to have any chance at all of this towering process working, we 74 | had better make sure that each layer is robust and sturdy. 75 | 76 | All of this is to say that compositional systems work not because they are 77 | fundamentally better, but because they are the only systems we humans have 78 | a reasonable chance of understanding. Composition isn't sufficient for success, 79 | but make no mistake---it certainly is necessary. 80 | 81 | *Therefore:* 82 | 83 | **Seek composition in all of your cognitive endeavors---especially software, of 84 | which we will place special emphasis in this book. Build composable designs. 85 | Furthermore, keep an extremely wary eye of any non-compositional systems, which 86 | will always grow too complicated to be understood, and which therefore will 87 | always contain bugs and disorganized designs.** 88 | 89 | --- 90 | 91 | Use [composition-of-understanding]() to ensure your problem domain is 92 | comprehensible. Use [modeling-with-types]() to flesh out the meaningful 93 | interactions between parts, and give the implementation in terms of 94 | [composition-of-implementations](). [composition-of-functions]() will play 95 | a large role in this. Ensure that each piece of the implementation does its job 96 | well, and rely on [composition-of-correctness]() to scale the system. 97 | -------------------------------------------------------------------------------- /book/composition2.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: composition2 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: 8 | - composition-of-correctness 9 | - composition-of-functions 10 | - composition-of-implementations 11 | - composition-of-understanding 12 | - types 13 | see-also: [] 14 | name: "Composition2" 15 | teaser: "" 16 | --- 17 | 18 | Moreso than any other 19 | 20 | The average software library is resoundingly non-composition; therefore, it can 21 | be hard to spot---if only due to being a proverbial fish in water. To take 22 | a concrete example, consider the popular protobuffer IDL. Protobuffer, like 23 | other interface description languages, is used to give a schema for sending 24 | records over the wire. The purpose is to define your datatype once, and 25 | generate code for it in any language in which you might be communicating. 26 | 27 | As an example of what a protobuffer definition looks like, the following is 28 | straight out of the language guide: 29 | 30 | ```protobuffer 31 | message Example { 32 | string query = 1; 33 | int32 page_number = 2; 34 | int32 results_per_page = 3; 35 | } 36 | ``` 37 | 38 | The exact details here don't matter, but this defines a new record called 39 | `Example`, with three fields. You can see that each field comes with an 40 | associated type. Besides the "usual" types---things like `string`, `bool`, 41 | `int32`---protobuffer has some support for type operators. For example, you can 42 | mark a field as `repeated`: 43 | 44 | ```protobuffer 45 | message Example2 { 46 | int32 userid = 1; 47 | repeated int32 relationships = 2; 48 | } 49 | ``` 50 | 51 | which says that in a given `Example2`, we will have exactly one `userid`, but 52 | zero or more `relationship`s. In essence, `repeated` turns a field of type `T` 53 | into a list, or array, of `T`s. Despite the presence of one instance of 54 | `repeated` turning a field into a 1D array, we cannot use `repeated repeated` 55 | to turn a field into a 2D array. 56 | 57 | In other words, the `repeated` construct cannot be composed with itself. 58 | However desirable it might be for your business logic to be able to articulate 59 | 2D arrays, you are nevertheless stuck. 60 | 61 | Consider another example, also from protobuffers. It's often desirable to 62 | articulate "at most one of these fields is present" (a 63 | [coproduct][coproduct])---for example, I might need to maintain both a legacy 64 | and new version of an order system. Therefore, in processing an order, I might 65 | have the legacy version of the data structure, or the new one, and my software 66 | ought to be able to handle either. 67 | 68 | We can express this situation in protobuffer via a `oneof` field: 69 | 70 | ```protobuffer 71 | message OrderStatusReq { 72 | oneof order_container { 73 | LegacyOrder legacy_order = 1; 74 | Order order = 2; 75 | } 76 | } 77 | ``` 78 | 79 | But these `oneof` fields are also noncompositional; they can't be combined with 80 | `repeated` fields. That is to say, neither can I make an array of things which 81 | are one of `LegacyOrder` or `Order`, nor can I make a `oneof` of fields which 82 | are themselves arrays. 83 | 84 | How does one get into this situation? Usually it is caused by having an 85 | implementation in mind when you design the abstraction. This is at odds with 86 | [applications-want-to-be-libraries][applications-want-to-be-libraries]---recall 87 | that the hallmark of lasting software is its ability to solve problems that the 88 | author never thought of. Composition, by its very nature, allows for all 89 | meaningful combinations of concepts---the crushing majority of which will never 90 | be discovered by any human, but which is guaranteed to work regardless. 91 | 92 | -------------------------------------------------------------------------------- /book/computing-is-not-about-computers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: computing-is-not-about-computers 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | smaller: 8 | - thinking-about-performance-gets-in-the-way 9 | see-also: [] 10 | name: "computing-is-not-about-computers" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/concepts.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: concepts 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - computing-is-not-about-computers 8 | - effects 9 | - functions 10 | - illegal-states-are-unrepresentable 11 | - introduction-and-elimination 12 | - laws 13 | - parallel-over-sequential 14 | - pure-over-effectful 15 | - reusable-vocabulary 16 | - separate-interface-and-implementation 17 | - syntax-and-semantics 18 | - the-best-abstractions-already-exist 19 | - totality 20 | - types-and-values 21 | see-also: [] 22 | name: "concepts" 23 | teaser: "" 24 | --- 25 | 26 | 27 | ...bigger context... 28 | 29 | --- 30 | 31 | TODO(sandy): main body 32 | 33 | --- 34 | 35 | ...smaller context... 36 | -------------------------------------------------------------------------------- /book/coproducts.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: coproducts 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: 8 | - vs-union-types 9 | see-also: [] 10 | name: "coproducts" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/copy-on-write.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: copy-on-write 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - sharing 7 | - tricks 8 | smaller: [] 9 | see-also: [] 10 | name: "copy-on-write" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/correctness.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: correctness 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - desiderata 7 | smaller: 8 | - composition-of-correctness 9 | - illegal-states-are-unrepresentable 10 | - laws 11 | - simplicity 12 | see-also: [] 13 | name: "correctness" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/cps.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: cps 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - final-encodings 7 | - tricks 8 | smaller: 9 | - trampolining 10 | see-also: [] 11 | name: "cps" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/custom-control-flow.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: custom-control-flow 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - higher-order-functions 7 | - tools 8 | smaller: [] 9 | see-also: [] 10 | name: "custom-control-flow" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/data-dependency.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: data-dependency 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - monads-are-overused 9 | - parallel-over-sequential 10 | see-also: [] 11 | name: "data-dependency" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/denotations.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: denotations 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - syntax-and-semantics 7 | smaller: 8 | - composition-of-understanding 9 | see-also: [] 10 | name: "denotations" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/derive-performance-from-the-problem.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: derive-performance-from-the-problem 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - algebraic-properties 7 | - thinking-about-performance-gets-in-the-way 8 | smaller: 9 | - structural-diffing 10 | see-also: [] 11 | name: "derive-performance-from-the-problem" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/desiderata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: desiderata 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - correctness 8 | - empathy 9 | - flexibility 10 | - simplicity 11 | see-also: [] 12 | name: "desiderata" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/diagram-envelopes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: diagram-envelopes 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - acccumulating-caches 7 | smaller: [] 8 | see-also: [] 9 | name: "diagram-envelopes" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/dlists.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: dlists 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - yoneda-embeddings 7 | smaller: 8 | - endos 9 | see-also: [] 10 | name: "dlists" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/dynamic-programming.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: dynamic-programming 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - memoization 7 | smaller: [] 8 | see-also: [] 9 | name: "Dynamic Programming" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/effects.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: effects 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - purity 8 | smaller: 9 | - applicatives 10 | - monads 11 | - monads-are-overused 12 | see-also: [] 13 | name: "effects" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/either.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: either 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - alternatives 7 | - common-types 8 | smaller: 9 | - partial-functions 10 | see-also: [] 11 | name: "either" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/empathy.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: empathy 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - desiderata 7 | smaller: 8 | - illegal-states-are-unrepresentable 9 | - laws 10 | see-also: [] 11 | name: "empathy" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/endos.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: endos 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - dlists 7 | - function-monoids 8 | smaller: [] 9 | see-also: [] 10 | name: "endos" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/existentializing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: existentializing 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - quantifiers 7 | smaller: 8 | - existentials-as-arguments 9 | - unsafe-coerce-the-existential 10 | see-also: [] 11 | name: "existentializing" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/existentials-as-arguments.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: existentials-as-arguments 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - antipatterns 7 | - existentializing 8 | smaller: [] 9 | see-also: [] 10 | name: "existentials-as-arguments" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/final-encodings.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: final-encodings 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - cps 9 | see-also: [] 10 | name: "final-encodings" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/finger-trees.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: finger-trees 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - acccumulating-caches 7 | - nonregular-recursion 8 | smaller: [] 9 | see-also: [] 10 | name: "finger-trees" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/flexibility.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: flexibility 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - desiderata 7 | - simplicity 8 | smaller: 9 | - open-world-assumption 10 | see-also: [] 11 | name: "flexibility" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/foldmaps.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: foldmaps 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-iterations 7 | smaller: 8 | - monoids 9 | see-also: [] 10 | name: "foldmaps" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/folds.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: folds 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - recursion-schemes 7 | smaller: [] 8 | see-also: [] 9 | name: "folds" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/forall.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: forall 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - quantifiers 7 | smaller: [] 8 | see-also: [] 9 | name: "forall" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/function-monoids.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: function-monoids 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - monoids 7 | smaller: 8 | - endos 9 | - pointwise-monoid 10 | see-also: [] 11 | name: "function-monoids" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/function-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: function-types 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "function-types" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: functions 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - totality 8 | smaller: 9 | - composition-of-functions 10 | - partial-functions 11 | see-also: [] 12 | name: "functions" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/functors.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: functors 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - compose-type 8 | - maps 9 | smaller: [] 10 | see-also: [] 11 | name: "functors" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/gadts.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: gadts 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "gadts" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/higher-order-functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: higher-order-functions 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - tools 7 | smaller: 8 | - custom-control-flow 9 | - precomposition 10 | see-also: [] 11 | name: "higher-order-functions" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/i1.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: i1 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "i1" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/if-it-compiles-it-works.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: if-it-compiles-it-works 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - illegal-states-are-unrepresentable 7 | - philosophy 8 | - simplicity 9 | smaller: [] 10 | see-also: [] 11 | name: "if-it-compiles-it-works" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/illegal-states-are-unrepresentable.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: illegal-states-are-unrepresentable 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - correctness 8 | - empathy 9 | smaller: 10 | - if-it-compiles-it-works 11 | - smart-constructors 12 | - totality 13 | - type-variables 14 | - well-typed 15 | see-also: [] 16 | name: "illegal-states-are-unrepresentable" 17 | teaser: "" 18 | --- 19 | 20 | 21 | ...bigger context... 22 | 23 | --- 24 | 25 | TODO(sandy): main body 26 | 27 | --- 28 | 29 | ...smaller context... 30 | -------------------------------------------------------------------------------- /book/infinite-data-structures.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: infinite-data-structures 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - comonads 9 | see-also: [] 10 | name: "infinite-data-structures" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/initial-encodings.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: initial-encodings 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - codensity 9 | see-also: [] 10 | name: "initial-encodings" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/introduction-and-elimination.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: introduction-and-elimination 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | smaller: [] 8 | see-also: [] 9 | name: "introduction-and-elimination" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/isomorphisms.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: isomorphisms 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - there-and-back-again 9 | see-also: [] 10 | name: "isomorphisms" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/laws.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: laws 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - correctness 8 | - empathy 9 | - property-tests 10 | smaller: 11 | - algebraic-properties 12 | - reusable-vocabulary 13 | see-also: [] 14 | name: "laws" 15 | teaser: "" 16 | --- 17 | 18 | 19 | ...bigger context... 20 | 21 | --- 22 | 23 | TODO(sandy): main body 24 | 25 | --- 26 | 27 | ...smaller context... 28 | -------------------------------------------------------------------------------- /book/lists.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: lists 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - alternatives 7 | - common-types 8 | smaller: [] 9 | see-also: [] 10 | name: "lists" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/maps.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: maps 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-iterations 7 | smaller: 8 | - functors 9 | see-also: [] 10 | name: "maps" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/maybe.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: maybe 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - alternatives 7 | - common-types 8 | smaller: 9 | - partial-functions 10 | see-also: [] 11 | name: "maybe" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/memoization.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: memoization 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - representable-functors 7 | smaller: 8 | - dyanmic-programming 9 | see-also: [] 10 | name: "Memoization" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | 25 | -------------------------------------------------------------------------------- /book/modeling-with-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: modeling-with-types 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition 7 | - tools 8 | - totality 9 | smaller: 10 | - newtypes-over-aliases 11 | - smart-constructors 12 | - types 13 | - combinator-libraries 14 | see-also: [] 15 | name: "Modeling with Types" 16 | teaser: "" 17 | --- 18 | 19 | 20 | ...suppose that you have already a rudimentary and informal understanding of 21 | the problem domain. Now, extract exactness by hashing out the objects of study 22 | and the interrelations between them. 23 | 24 | --- 25 | 26 | **Types define the universe of discourse, and functions between them articulate 27 | the meaningful things we can say about them. Types are the most successful 28 | organizing technique for taming complexity in software.** 29 | 30 | When building a software library (which is to say, when building any 31 | software---[applications-want-to-be-libraries]()), the most salient question is 32 | "what is this library *about*?" In answering this question, you will come up 33 | with a series of domain objects that are worth being able to discuss in 34 | software. 35 | 36 | For example, an audio processing library might require concepts of audio files, 37 | waveforms, frequencies, pitches, and time. A database library might have 38 | data stores, schemas, rows, columns, fields, transactions, and so on. A UI 39 | toolkit might have windows, scrollbars, text entry elements, cursors, and 40 | buttons. 41 | 42 | Even when working in an untyped language, the types exist behind the scenes. 43 | 44 | --- 45 | 46 | ...smaller context... 47 | -------------------------------------------------------------------------------- /book/monads-are-overused.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: monads-are-overused 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - antipatterns 7 | - applications-want-to-be-libraries 8 | - data-dependency 9 | - effects 10 | - monads 11 | smaller: [] 12 | see-also: [] 13 | name: "monads-are-overused" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/monads.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: monads 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - effects 8 | - parallel-over-sequential 9 | - trampolining 10 | smaller: 11 | - monads-are-overused 12 | see-also: [] 13 | name: "monads" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/monoids.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: monoids 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - foldmaps 8 | smaller: 9 | - acccumulating-caches 10 | - function-monoids 11 | - validation 12 | see-also: [] 13 | name: "monoids" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/mu.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: mu 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "mu" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/newtypes-over-aliases.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: newtypes-over-aliases 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - modeling-with-types 7 | smaller: [] 8 | see-also: [] 9 | name: "newtypes-over-aliases" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/nonregular-recursion.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nonregular-recursion 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - tools 7 | smaller: 8 | - finger-trees 9 | - precomposition 10 | see-also: [] 11 | name: "nonregular-recursion" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/nu.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: nu 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "nu" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/only-local-coherence.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: only-local-coherence 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - open-world-assumption 7 | smaller: [] 8 | see-also: [] 9 | name: "only-local-coherence" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/open-world-assumption.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: open-world-assumption 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - flexibility 7 | - philosophy 8 | smaller: 9 | - only-local-coherence 10 | see-also: [] 11 | name: "open-world-assumption" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/parallel-over-sequential.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: parallel-over-sequential 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - data-dependency 8 | - pure-over-effectful 9 | smaller: 10 | - applicatives 11 | - monads 12 | see-also: [] 13 | name: "parallel-over-sequential" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/parsers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: parsers 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - combinator-libraries 7 | - problems 8 | smaller: [] 9 | see-also: [] 10 | name: "parsers" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/partial-functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: partial-functions 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - antipatterns 7 | - either 8 | - functions 9 | - maybe 10 | - theory 11 | smaller: [] 12 | see-also: [] 13 | name: "partial-functions" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/philosophy.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: philosophy 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - applications-want-to-be-libraries 8 | - code-reifies-understanding 9 | - composition 10 | - if-it-compiles-it-works 11 | - open-world-assumption 12 | - purity 13 | - understanding-before-implementation 14 | - what-not-how 15 | see-also: [] 16 | name: "The Philosophy of Functional Programming" 17 | teaser: "" 18 | --- 19 | 20 | **Programs are made up of smaller programs.** 21 | 22 | This is the fundamental tenet of the functional programming. Don't be deceived 23 | by the terseness of this slogan---it packs a great deal of depth in its seven 24 | words. 25 | 26 | We can understand this in two ways. One way of parsing the importance is that 27 | programs *are made up of* smaller programs. How does one build a large program? 28 | By combining smaller programs together. Of course, this only gives rise to 29 | further questions. In what ways can programs be combined? Is combining program 30 | `A` with program `B` the same as combining B with A? Can any two programs be 31 | combined, or are there limitations? If programs `A` and `B` both have some 32 | property `p`, is it guaranteed that their combination will also satisfy `p`? 33 | 34 | Already this suggests a very different way of thinking about programming than 35 | you are likely familiar with. Under the functional lens, programs become 36 | objects to be manipulated---as tangible as the booleans and unsigned integers, 37 | but significantly more expressive. 38 | 39 | Another parsing of our slogan is that programs are made up of *smaller 40 | programs.* This gestures towards other intriguing questions. Is there a smallest 41 | program? Are the smaller programs individually meaningful? Is the larger program 42 | merely the sum of its parts? Can we arbitrarily divide a program, or must it 43 | split only along pre-existing "fracture lines?" 44 | 45 | These are the sorts of questions answered in this book. But these questions are 46 | not merely academic trivia; they have profound consequences for the engineer 47 | attempting to build real-world software systems. Intuition for writing software 48 | can get one only so far; inevitably you will encounter a sufficiently-difficult 49 | problem that defies all intuitive means of tackling it. In these situations, 50 | knowing how to carve programs at their joints will be immeasurably helpful. 51 | 52 | --- 53 | 54 | Software is a means to an end ([what-not-how](), 55 | [code-reifies-understanding]()). Knowing what problem you're tackling, and being 56 | able to identify a solution when you see one, must come 57 | first---[understanding-before-implementation](). Programs are built out of 58 | smaller programs ([composition]()) and, importantly, 59 | [applications-want-to-be-libraries](). These principles are significantly easier 60 | to follow when our code is pure ([purity]()) and under an open-world assumption 61 | ([open-world-assumption]()). Composition of meaning means that often 62 | [if-it-compiles-it-works](). 63 | 64 | -------------------------------------------------------------------------------- /book/pointwise-monoid.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: pointwise-monoid 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - function-monoids 7 | smaller: [] 8 | see-also: [] 9 | name: "pointwise-monoid" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/precomposition.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: precomposition 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - higher-order-functions 7 | - nonregular-recursion 8 | - tricks 9 | smaller: [] 10 | see-also: [] 11 | name: "precomposition" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/problems.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: problems 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - parsers 8 | - structural-problems 9 | see-also: [] 10 | name: "problems" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/products.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: products 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "products" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/property-tests.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: property-tests 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - testing 7 | smaller: 8 | - algebraic-properties 9 | - laws 10 | - there-and-back-again 11 | see-also: [] 12 | name: "property-tests" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/pure-over-effectful.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: pure-over-effectful 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - purity 8 | smaller: 9 | - parallel-over-sequential 10 | see-also: [] 11 | name: "pure-over-effectful" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/purity.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: purity 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: 8 | - effects 9 | - pure-over-effectful 10 | - sharing 11 | - structural-diffing 12 | see-also: [] 13 | name: "purity" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/quantifiers.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: quantifiers 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - theory 7 | smaller: 8 | - existentializing 9 | - forall 10 | see-also: [] 11 | name: "quantifiers" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/recursion-schemes.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: recursion-schemes 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-iterations 7 | - structural-programming 8 | - tools 9 | smaller: 10 | - folds 11 | - unfolds 12 | see-also: [] 13 | name: "recursion-schemes" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/representable-functors.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: representable-functors 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - functors 7 | - traversals 8 | - theory 9 | smaller: 10 | - memoization 11 | see-also: [] 12 | name: "Representable Functors" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | 27 | -------------------------------------------------------------------------------- /book/reusable-vocabulary.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: reusable-vocabulary 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - laws 8 | smaller: 9 | - bend-it-to-fit-the-abstraction 10 | - common-typeclasses 11 | - the-best-abstractions-already-exist 12 | see-also: [] 13 | name: "reusable-vocabulary" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /book/selectives.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: selectives 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | - compose-type 8 | smaller: [] 9 | see-also: [] 10 | name: "selectives" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/semilattices.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: semilattices 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-typeclasses 7 | smaller: [] 8 | see-also: [] 9 | name: "semilattices" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/separate-interface-and-implementation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: separate-interface-and-implementation 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - syntax-and-semantics 8 | smaller: [] 9 | see-also: [] 10 | name: "separate-interface-and-implementation" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/sharing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: sharing 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - purity 7 | - thinking-about-performance-gets-in-the-way 8 | smaller: 9 | - copy-on-write 10 | see-also: [] 11 | name: "sharing" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/simplicity.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: simplicity 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - correctness 7 | - desiderata 8 | smaller: 9 | - flexibility 10 | - if-it-compiles-it-works 11 | see-also: [] 12 | name: "simplicity" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/smart-constructors.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: smart-constructors 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - illegal-states-are-unrepresentable 7 | - modeling-with-types 8 | - tools 9 | smaller: [] 10 | see-also: [] 11 | name: "smart-constructors" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/structural-diffing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: structural-diffing 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - derive-performance-from-the-problem 7 | - purity 8 | - tricks 9 | smaller: [] 10 | see-also: [] 11 | name: "structural-diffing" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/structural-problems.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: structural-problems 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - problems 7 | smaller: 8 | - structural-programming 9 | see-also: [] 10 | name: "structural-problems" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/structural-programming.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: structural-programming 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - structural-problems 7 | - tools 8 | - types 9 | smaller: 10 | - recursion-schemes 11 | see-also: [] 12 | name: "structural-programming" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/syntax-and-semantics.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: syntax-and-semantics 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | smaller: 8 | - denotations 9 | - separate-interface-and-implementation 10 | see-also: [] 11 | name: "syntax-and-semantics" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/testing.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: testing 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - property-tests 8 | see-also: [] 9 | name: "testing" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/the-best-abstractions-already-exist.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: the-best-abstractions-already-exist 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - reusable-vocabulary 8 | smaller: 9 | - common-iterations 10 | - common-typeclasses 11 | see-also: [] 12 | name: "the-best-abstractions-already-exist" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/theory.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: theory 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - common-typeclasses 8 | - data-dependency 9 | - final-encodings 10 | - infinite-data-structures 11 | - initial-encodings 12 | - isomorphisms 13 | - partial-functions 14 | - quantifiers 15 | - yoneda-embeddings 16 | see-also: [] 17 | name: "theory" 18 | teaser: "" 19 | --- 20 | 21 | 22 | ...bigger context... 23 | 24 | --- 25 | 26 | TODO(sandy): main body 27 | 28 | --- 29 | 30 | ...smaller context... 31 | -------------------------------------------------------------------------------- /book/there-and-back-again.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: there-and-back-again 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - isomorphisms 7 | - property-tests 8 | smaller: [] 9 | see-also: [] 10 | name: "there-and-back-again" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/thinking-about-performance-gets-in-the-way.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: thinking-about-performance-gets-in-the-way 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - computing-is-not-about-computers 7 | smaller: 8 | - derive-performance-from-the-problem 9 | - sharing 10 | see-also: [] 11 | name: "thinking-about-performance-gets-in-the-way" 12 | teaser: "" 13 | --- 14 | 15 | 16 | ...bigger context... 17 | 18 | --- 19 | 20 | TODO(sandy): main body 21 | 22 | --- 23 | 24 | ...smaller context... 25 | -------------------------------------------------------------------------------- /book/tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tools 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - combinator-libraries 8 | - custom-control-flow 9 | - higher-order-functions 10 | - modeling-with-types 11 | - nonregular-recursion 12 | - recursion-schemes 13 | - smart-constructors 14 | - structural-programming 15 | - type-variables 16 | see-also: [] 17 | name: "tools" 18 | teaser: "" 19 | --- 20 | 21 | 22 | ...bigger context... 23 | 24 | --- 25 | 26 | TODO(sandy): main body 27 | 28 | --- 29 | 30 | ...smaller context... 31 | -------------------------------------------------------------------------------- /book/totality.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: totality 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | - illegal-states-are-unrepresentable 8 | smaller: 9 | - functions 10 | - modeling-with-types 11 | see-also: [] 12 | name: "totality" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/trampolining.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: trampolining 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - composition-of-functions 7 | - cps 8 | - tricks 9 | smaller: 10 | - monads 11 | see-also: [] 12 | name: "trampolining" 13 | teaser: "" 14 | --- 15 | 16 | 17 | ...bigger context... 18 | 19 | --- 20 | 21 | TODO(sandy): main body 22 | 23 | --- 24 | 25 | ...smaller context... 26 | -------------------------------------------------------------------------------- /book/traversals.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: traversals 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - common-iterations 7 | smaller: 8 | - applicatives 9 | see-also: [] 10 | name: "traversals" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/tricks.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: tricks 3 | confidence: 7 4 | tags: [] 5 | bigger: [] 6 | smaller: 7 | - acccumulating-caches 8 | - asymptotic-improvement 9 | - copy-on-write 10 | - cps 11 | - precomposition 12 | - structural-diffing 13 | - trampolining 14 | - yoneda-embeddings 15 | see-also: [] 16 | name: "tricks" 17 | teaser: "" 18 | --- 19 | 20 | 21 | ...bigger context... 22 | 23 | --- 24 | 25 | TODO(sandy): main body 26 | 27 | --- 28 | 29 | ...smaller context... 30 | -------------------------------------------------------------------------------- /book/type-variables.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: type-variables 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - illegal-states-are-unrepresentable 7 | - tools 8 | smaller: [] 9 | see-also: [] 10 | name: "type-variables" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/types-and-values.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: types-and-values 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - concepts 7 | smaller: [] 8 | see-also: [] 9 | name: "types-and-values" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: types 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - modeling-with-types 7 | - well-typed 8 | smaller: 9 | - adts 10 | - common-types 11 | - compose-type 12 | - coproducts 13 | - function-types 14 | - gadts 15 | - i1 16 | - mu 17 | - nu 18 | - products 19 | - structural-programming 20 | - u1 21 | - v1 22 | see-also: [] 23 | name: "types" 24 | teaser: "" 25 | --- 26 | 27 | 28 | ...bigger context... 29 | 30 | --- 31 | 32 | TODO(sandy): main body 33 | 34 | --- 35 | 36 | ...smaller context... 37 | -------------------------------------------------------------------------------- /book/u1.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: u1 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "u1" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/understanding-before-implementation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: understanding-before-implementation 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: [] 8 | see-also: [] 9 | name: "understanding-before-implementation" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/unfolds.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: unfolds 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - recursion-schemes 7 | smaller: [] 8 | see-also: [] 9 | name: "unfolds" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/unsafe-coerce-the-existential.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: unsafe-coerce-the-existential 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - antipatterns 7 | - existentializing 8 | smaller: [] 9 | see-also: [] 10 | name: "unsafe-coerce-the-existential" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/v1.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: v1 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - types 7 | smaller: [] 8 | see-also: [] 9 | name: "v1" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/validation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: validation 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - applicatives 7 | - monoids 8 | smaller: [] 9 | see-also: [] 10 | name: "validation" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/vs-union-types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: vs-union-types 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - antipatterns 7 | - coproducts 8 | smaller: [] 9 | see-also: [] 10 | name: "vs-union-types" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/well-typed.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: well-typed 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - illegal-states-are-unrepresentable 7 | smaller: 8 | - types 9 | see-also: [] 10 | name: "well-typed" 11 | teaser: "" 12 | --- 13 | 14 | 15 | ...bigger context... 16 | 17 | --- 18 | 19 | TODO(sandy): main body 20 | 21 | --- 22 | 23 | ...smaller context... 24 | -------------------------------------------------------------------------------- /book/what-not-how.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: what-not-how 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - philosophy 7 | smaller: [] 8 | see-also: [] 9 | name: "what-not-how" 10 | teaser: "" 11 | --- 12 | 13 | 14 | ...bigger context... 15 | 16 | --- 17 | 18 | TODO(sandy): main body 19 | 20 | --- 21 | 22 | ...smaller context... 23 | -------------------------------------------------------------------------------- /book/yoneda-embeddings.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: yoneda-embeddings 3 | confidence: 7 4 | tags: [] 5 | bigger: 6 | - asymptotic-improvement 7 | - theory 8 | - tricks 9 | smaller: 10 | - codensity 11 | - dlists 12 | see-also: [] 13 | name: "yoneda-embeddings" 14 | teaser: "" 15 | --- 16 | 17 | 18 | ...bigger context... 19 | 20 | --- 21 | 22 | TODO(sandy): main body 23 | 24 | --- 25 | 26 | ...smaller context... 27 | -------------------------------------------------------------------------------- /enstructer/.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work/ 2 | *~ -------------------------------------------------------------------------------- /enstructer/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog for `enstructer` 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to the 7 | [Haskell Package Versioning Policy](https://pvp.haskell.org/). 8 | 9 | ## Unreleased 10 | 11 | ## 0.1.0.0 - YYYY-MM-DD 12 | -------------------------------------------------------------------------------- /enstructer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024 Sandy Maguire 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /enstructer/README.md: -------------------------------------------------------------------------------- 1 | # enstructer 2 | -------------------------------------------------------------------------------- /enstructer/Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /enstructer/app/Main.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Lib 4 | 5 | main :: IO () 6 | main = someFunc 7 | -------------------------------------------------------------------------------- /enstructer/enstructer.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.2 2 | 3 | -- This file has been generated from package.yaml by hpack version 0.36.0. 4 | -- 5 | -- see: https://github.com/sol/hpack 6 | 7 | name: enstructer 8 | version: 0.1.0.0 9 | description: Please see the README on GitHub at 10 | homepage: https://github.com/isovector/enstructer#readme 11 | bug-reports: https://github.com/isovector/enstructer/issues 12 | author: Sandy Maguire 13 | maintainer: sandy@sandymaguire.me 14 | copyright: 2024 Sandy Maguire 15 | license: BSD-3-Clause 16 | license-file: LICENSE 17 | build-type: Simple 18 | extra-source-files: 19 | README.md 20 | CHANGELOG.md 21 | 22 | source-repository head 23 | type: git 24 | location: https://github.com/isovector/enstructer 25 | 26 | library 27 | exposed-modules: 28 | Lib 29 | other-modules: 30 | Paths_enstructer 31 | autogen-modules: 32 | Paths_enstructer 33 | hs-source-dirs: 34 | src 35 | ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints 36 | build-depends: 37 | algebraic-graphs 38 | , base >=4.7 && <5 39 | , containers 40 | , megaparsec 41 | default-language: Haskell2010 42 | 43 | executable enstructer-exe 44 | main-is: Main.hs 45 | other-modules: 46 | Paths_enstructer 47 | autogen-modules: 48 | Paths_enstructer 49 | hs-source-dirs: 50 | app 51 | ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N 52 | build-depends: 53 | algebraic-graphs 54 | , base >=4.7 && <5 55 | , containers 56 | , enstructer 57 | , megaparsec 58 | default-language: Haskell2010 59 | -------------------------------------------------------------------------------- /enstructer/package.yaml: -------------------------------------------------------------------------------- 1 | name: enstructer 2 | version: 0.1.0.0 3 | github: "isovector/enstructer" 4 | license: BSD-3-Clause 5 | author: "Sandy Maguire" 6 | maintainer: "sandy@sandymaguire.me" 7 | copyright: "2024 Sandy Maguire" 8 | 9 | extra-source-files: 10 | - README.md 11 | - CHANGELOG.md 12 | 13 | # Metadata used when publishing your package 14 | # synopsis: Short description of your package 15 | # category: Web 16 | 17 | # To avoid duplicated efforts in documentation and dealing with the 18 | # complications of embedding Haddock markup inside cabal files, it is 19 | # common to point users to the README.md file. 20 | description: Please see the README on GitHub at 21 | 22 | dependencies: 23 | - base >= 4.7 && < 5 24 | - algebraic-graphs 25 | - containers 26 | - megaparsec 27 | 28 | ghc-options: 29 | - -Wall 30 | - -Wcompat 31 | - -Widentities 32 | - -Wincomplete-record-updates 33 | - -Wincomplete-uni-patterns 34 | - -Wpartial-fields 35 | - -Wredundant-constraints 36 | 37 | library: 38 | source-dirs: src 39 | 40 | executables: 41 | enstructer-exe: 42 | main: Main.hs 43 | source-dirs: app 44 | ghc-options: 45 | - -threaded 46 | - -rtsopts 47 | - -with-rtsopts=-N 48 | dependencies: 49 | - enstructer 50 | -------------------------------------------------------------------------------- /enstructer/src/Lib.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DeriveGeneric #-} 2 | {-# LANGUAGE DerivingStrategies #-} 3 | {-# LANGUAGE DerivingVia #-} 4 | {-# LANGUAGE ImportQualifiedPost #-} 5 | {-# LANGUAGE OverloadedStrings #-} 6 | 7 | module Lib where 8 | 9 | import Data.Foldable 10 | import Data.List (isPrefixOf) 11 | import Data.Char 12 | import Control.Applicative hiding (many) 13 | import Data.Void 14 | import Algebra.Graph.AdjacencyMap qualified as G 15 | import Data.IntMap (IntMap) 16 | import Data.IntMap qualified as IM 17 | import GHC.Generics 18 | import Text.Megaparsec 19 | import Text.Megaparsec.Char (space1, char) 20 | import Text.Megaparsec.Char.Lexer 21 | import Data.Either 22 | 23 | 24 | type Parser = Parsec Void String 25 | 26 | data G = G 27 | { g_gr :: G.AdjacencyMap Int 28 | , g_map :: IntMap String 29 | } 30 | deriving stock (Generic, Show) 31 | deriving (Semigroup, Monoid) via Generically G 32 | 33 | mkG :: G -> G.AdjacencyMap String 34 | mkG (G gr m) = G.gmap (m IM.!) gr 35 | 36 | sp :: Parser () 37 | sp = space space1 empty empty 38 | 39 | parseIt :: Parser G 40 | parseIt = asum 41 | [ try $ do 42 | ix <- lexeme sp decimal 43 | symbol sp "[" 44 | lexeme sp "label" 45 | symbol sp "=" 46 | str <- fmap getName stringLiteral 47 | symbol sp "]" 48 | symbol sp ";" 49 | pure $ G (G.vertex ix) $ IM.singleton ix str 50 | , do 51 | ix <- lexeme sp decimal 52 | symbol sp "->" 53 | jx <- lexeme sp decimal 54 | symbol sp ";" 55 | pure $ G (G.edge ix jx) mempty 56 | ] 57 | 58 | stringLiteral :: Parser String 59 | stringLiteral = char '"' >> manyTill charLiteral (char '"') 60 | 61 | 62 | 63 | parseG :: String -> G 64 | parseG = fromRight (error "cant parse") . parse parseIt "" 65 | 66 | 67 | toYaml :: [String] -> String 68 | toYaml [] = " []" 69 | toYaml x = mappend "\n" $ init $ unlines $ fmap (mappend "- ") x 70 | 71 | 72 | main :: IO () 73 | main = do 74 | f <- readFile "../test.dot" 75 | let g = mkG $ foldMap parseG $ lines f 76 | for_ (G.vertexList g) $ \v -> do 77 | let ins = toList $ G.preSet v g 78 | outs = toList $ G.postSet v g 79 | let fp = "../book/" <> v <> ".md" 80 | writeFile fp $ unlines 81 | [ "---" 82 | , "id: " <> v 83 | , "confidence: 7" 84 | , "tags: []" 85 | , "bigger:" <> toYaml ins 86 | , "smaller:" <> toYaml outs 87 | , "see-also:" <> toYaml [] 88 | , "name: " <> show v 89 | , "teaser: " <> show "" 90 | , "---" 91 | , "" 92 | , "" 93 | , "...bigger context..." 94 | , "" 95 | , "---" 96 | , "" 97 | , "TODO(sandy): main body" 98 | , "" 99 | , "---" 100 | , "" 101 | , "...smaller context..." 102 | ] 103 | 104 | 105 | getName :: String -> String 106 | getName = betterName . foldMap unspace . fmap toLower 107 | where 108 | unspace ' ' = "-" 109 | unspace '-' = "-" 110 | unspace x 111 | | isSymbol x = mempty 112 | | isPunctuation x = mempty 113 | | otherwise = pure x 114 | 115 | betterName :: String -> String 116 | betterName "aps" = "pointwise-monoid" 117 | betterName "compose" = "compose-type" 118 | betterName x | isPrefixOf "of-" x= "composition-" <> x 119 | betterName x = x 120 | -------------------------------------------------------------------------------- /enstructer/stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # https://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-21.13 12 | # resolver: nightly-2023-09-24 13 | # resolver: ghc-9.6.2 14 | # 15 | # The location of a snapshot can be provided as a file or url. Stack assumes 16 | # a snapshot provided as a file might change, whereas a url resource does not. 17 | # 18 | # resolver: ./custom-snapshot.yaml 19 | # resolver: https://example.com/snapshots/2023-01-01.yaml 20 | resolver: lts-21.14 21 | 22 | # User packages to be built. 23 | # Various formats can be used as shown in the example below. 24 | # 25 | # packages: 26 | # - some-directory 27 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 28 | # subdirs: 29 | # - auto-update 30 | # - wai 31 | packages: 32 | - . 33 | # Dependency packages to be pulled from upstream that are not in the resolver. 34 | # These entries can reference officially published versions as well as 35 | # forks / in-progress versions pinned to a git hash. For example: 36 | # 37 | # extra-deps: 38 | # - acme-missiles-0.3 39 | # - git: https://github.com/commercialhaskell/stack.git 40 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 41 | # 42 | # extra-deps: [] 43 | 44 | # Override default flag values for local packages and extra-deps 45 | # flags: {} 46 | 47 | # Extra package databases containing global packages 48 | # extra-package-dbs: [] 49 | 50 | # Control whether we use the GHC we find on the path 51 | # system-ghc: true 52 | # 53 | # Require a specific version of Stack, using version ranges 54 | # require-stack-version: -any # Default 55 | # require-stack-version: ">=2.13" 56 | # 57 | # Override the architecture used by Stack, especially useful on Windows 58 | # arch: i386 59 | # arch: x86_64 60 | # 61 | # Extra directories used by Stack for building 62 | # extra-include-dirs: [/path/to/dir] 63 | # extra-lib-dirs: [/path/to/dir] 64 | # 65 | # Allow a newer minor version of GHC than the snapshot specifies 66 | # compiler-check: newer-minor 67 | -------------------------------------------------------------------------------- /enstructer/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | sha256: 60e54c1ba3c1e7163acf6dafa9d56b2d3b23f88a31ad53a1c9d888f32561f8da 10 | size: 639819 11 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/14.yaml 12 | original: lts-21.14 13 | -------------------------------------------------------------------------------- /enstructer/test/Spec.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "Test suite not yet implemented" 3 | -------------------------------------------------------------------------------- /structure.graphml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Structuring Applications 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Applications wrap libraries 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Boring configuration stuff; setup the environment 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Libraries first 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | One library per domain 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Libraries solve problems 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | Model domains 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | Correspond to abstract solutions 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | Denotations 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | A library has a mental model 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | Properties of a good library 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | Impossible to use wrong 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | Solves the whole problem 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | Doesn't leak implementation 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | Much more applicable than the original usecase 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | Invisibly deals with failure 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | Imperative shell, functional core 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | Applications are hard to test; libraries easy 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | Makes illegal state unrepresentable 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | Decorate pattern 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | Accept necessary parameters together 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | Make new types for invariants 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | Divided into types and combinators 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | One type for each concept 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | Coherent slices of time 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | Model time explicitly 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | Combinators are ways of building objects 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | Conceptually simple, regardless of implementation 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | How to pick types? 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | What granularity? 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | Don't think ontologies/OOP poly 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | Does this constraint exist in the real world or only in our minds? 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | Don't use numbers for non-mathematical numbers 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | Boolean blindness 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | -------------------------------------------------------------------------------- /test.dot: -------------------------------------------------------------------------------- 1 | 0 [ label="PHILOSOPHY"]; 2 | 6 [ label="What, not how"]; 3 | 0 -> 6; 4 | 7 [ label="Code reifies understanding"]; 5 | 0 -> 7; 6 | 8 [ label="Composition"]; 7 | 0 -> 8; 8 | 9 [ label="Understanding before implementation"]; 9 | 0 -> 9; 10 | 10 [ label="Purity"]; 11 | 0 -> 10; 12 | 11 [ label="Applications want to be libraries"]; 13 | 0 -> 11; 14 | 90 [ label="If it compiles, it works"]; 15 | 0 -> 90; 16 | 117 [ label="Open world assumption"]; 17 | 0 -> 117; 18 | 1 [ label="CONCEPTS"]; 19 | 16 [ label="Syntax and Semantics"]; 20 | 1 -> 16; 21 | 18 [ label="Reusable Vocabulary"]; 22 | 1 -> 18; 23 | 19 [ label="The best abstractions already exist"]; 24 | 1 -> 19; 25 | 20 [ label="Introduction and Elimination"]; 26 | 1 -> 20; 27 | 21 [ label="Types and Values"]; 28 | 1 -> 21; 29 | 35 [ label="Illegal states are unrepresentable"]; 30 | 1 -> 35; 31 | 36 [ label="Separate interface and implementation"]; 32 | 1 -> 36; 33 | 37 [ label="Computing is not about computers"]; 34 | 1 -> 37; 35 | 40 [ label="Pure over effectful"]; 36 | 1 -> 40; 37 | 41 [ label="Parallel over sequential"]; 38 | 1 -> 41; 39 | 42 [ label="Laws"]; 40 | 1 -> 42; 41 | 55 [ label="Functions"]; 42 | 1 -> 55; 43 | 57 [ label="Effects"]; 44 | 1 -> 57; 45 | 116 [ label="Totality"]; 46 | 1 -> 116; 47 | 2 [ label="THEORY"]; 48 | 33 [ label="Common Typeclasses"]; 49 | 2 -> 33; 50 | 34 [ label="Yoneda Embeddings"]; 51 | 2 -> 34; 52 | 56 [ label="Data dependency"]; 53 | 2 -> 56; 54 | 89 [ label="Infinite Data Structures"]; 55 | 2 -> 89; 56 | 91 [ label="Isomorphisms"]; 57 | 2 -> 91; 58 | 95 [ label="Partial functions"]; 59 | 2 -> 95; 60 | 105 [ label="Quantifiers"]; 61 | 2 -> 105; 62 | 113 [ label="Initial encodings"]; 63 | 2 -> 113; 64 | 114 [ label="Final encodings"]; 65 | 2 -> 114; 66 | 3 [ label="TOOLS"]; 67 | 43 [ label="Combinator libraries"]; 68 | 3 -> 43; 69 | 53 [ label="Modeling with Types"]; 70 | 3 -> 53; 71 | 54 [ label="Structural programming"]; 72 | 3 -> 54; 73 | 63 [ label="Custom control flow"]; 74 | 3 -> 63; 75 | 64 [ label="Higher order functions"]; 76 | 3 -> 64; 77 | 66 [ label="Type variables"]; 78 | 3 -> 66; 79 | 72 [ label="Recursion Schemes"]; 80 | 3 -> 72; 81 | 75 [ label="Nonregular Recursion"]; 82 | 3 -> 75; 83 | 81 [ label="Smart constructors"]; 84 | 3 -> 81; 85 | 4 [ label="TRICKS"]; 86 | 4 -> 34; 87 | 62 [ label="Asymptotic Improvement"]; 88 | 4 -> 62; 89 | 68 [ label="Structural diffing"]; 90 | 4 -> 68; 91 | 69 [ label="Copy on write"]; 92 | 4 -> 69; 93 | 71 [ label="CPS"]; 94 | 4 -> 71; 95 | 73 [ label="Acccumulating caches"]; 96 | 4 -> 73; 97 | 87 [ label="Precomposition"]; 98 | 4 -> 87; 99 | 119 [ label="Trampolining"]; 100 | 4 -> 119; 101 | 5 [ label="PROBLEMS"]; 102 | 82 [ label="Parsers"]; 103 | 5 -> 82; 104 | 88 [ label="Structural problems"]; 105 | 5 -> 88; 106 | 22 [ label="Of functions"]; 107 | 8 -> 22; 108 | 23 [ label="Of implementations"]; 109 | 8 -> 23; 110 | 24 [ label="Of understanding"]; 111 | 8 -> 24; 112 | 25 [ label="Of correctness"]; 113 | 8 -> 25; 114 | 10 -> 40; 115 | 10 -> 57; 116 | 10 -> 68; 117 | 70 [ label="Sharing"]; 118 | 10 -> 70; 119 | 59 [ label="Monads are overused"]; 120 | 11 -> 59; 121 | 12 [ label="DESIDERATA"]; 122 | 13 [ label="Correctness"]; 123 | 12 -> 13; 124 | 14 [ label="Flexibility"]; 125 | 12 -> 14; 126 | 15 [ label="Empathy"]; 127 | 12 -> 15; 128 | 39 [ label="Simplicity"]; 129 | 12 -> 39; 130 | 13 -> 25; 131 | 13 -> 35; 132 | 13 -> 39; 133 | 13 -> 42; 134 | 14 -> 117; 135 | 15 -> 35; 136 | 15 -> 42; 137 | 17 [ label="Denotations"]; 138 | 16 -> 17; 139 | 16 -> 36; 140 | 17 -> 24; 141 | 18 -> 19; 142 | 18 -> 33; 143 | 67 [ label="Bend it to fit the abstraction"]; 144 | 18 -> 67; 145 | 19 -> 33; 146 | 76 [ label="Common Iterations"]; 147 | 19 -> 76; 148 | 22 -> 119; 149 | 23 -> 43; 150 | 24 -> 43; 151 | 25 -> 43; 152 | 26 [ label="Monoids"]; 153 | 26 -> 73; 154 | 101 [ label="Validation"]; 155 | 26 -> 101; 156 | 110 [ label="Function monoids"]; 157 | 26 -> 110; 158 | 27 [ label="Functors"]; 159 | 28 [ label="Applicatives"]; 160 | 28 -> 101; 161 | 29 [ label="Selectives"]; 162 | 30 [ label="Monads"]; 163 | 30 -> 59; 164 | 31 [ label="Semilattices"]; 165 | 32 [ label="Comonads"]; 166 | 33 -> 26; 167 | 33 -> 27; 168 | 33 -> 28; 169 | 33 -> 29; 170 | 33 -> 30; 171 | 33 -> 31; 172 | 33 -> 32; 173 | 100 [ label="Alternatives"]; 174 | 33 -> 100; 175 | 60 [ label="Dlists"]; 176 | 34 -> 60; 177 | 61 [ label="Codensity"]; 178 | 34 -> 61; 179 | 52 [ label="Well-typed"]; 180 | 35 -> 52; 181 | 35 -> 66; 182 | 35 -> 81; 183 | 35 -> 90; 184 | 35 -> 116; 185 | 38 [ label="Thinking about performance gets in the way"]; 186 | 37 -> 38; 187 | 38 -> 70; 188 | 86 [ label="Derive performance from the problem"]; 189 | 38 -> 86; 190 | 39 -> 14; 191 | 39 -> 90; 192 | 40 -> 41; 193 | 41 -> 28; 194 | 41 -> 30; 195 | 42 -> 18; 196 | 85 [ label="Algebraic properties"]; 197 | 42 -> 85; 198 | 43 -> 82; 199 | 44 [ label="Types"]; 200 | 45 [ label="U1"]; 201 | 44 -> 45; 202 | 46 [ label="V1"]; 203 | 44 -> 46; 204 | 47 [ label="Products"]; 205 | 44 -> 47; 206 | 48 [ label="Coproducts"]; 207 | 44 -> 48; 208 | 49 [ label="Mu"]; 209 | 44 -> 49; 210 | 50 [ label="Nu"]; 211 | 44 -> 50; 212 | 51 [ label="Function Types"]; 213 | 44 -> 51; 214 | 44 -> 54; 215 | 65 [ label="I1"]; 216 | 44 -> 65; 217 | 97 [ label="Common types"]; 218 | 44 -> 97; 219 | 109 [ label="Compose"]; 220 | 44 -> 109; 221 | 120 [ label="ADTS"]; 222 | 44 -> 120; 223 | 121 [ label="GADTs"]; 224 | 44 -> 121; 225 | 103 [ label="Vs union types"]; 226 | 48 -> 103; 227 | 52 -> 44; 228 | 53 -> 44; 229 | 53 -> 81; 230 | 102 [ label="Newtypes over aliases"]; 231 | 53 -> 102; 232 | 54 -> 72; 233 | 55 -> 22; 234 | 55 -> 95; 235 | 56 -> 41; 236 | 56 -> 59; 237 | 57 -> 28; 238 | 57 -> 30; 239 | 57 -> 59; 240 | 58 [ label="ANTIPATTERNS"]; 241 | 58 -> 59; 242 | 58 -> 95; 243 | 58 -> 103; 244 | 107 [ label="Unsafe coerce the existential"]; 245 | 58 -> 107; 246 | 108 [ label="Existentials as arguments"]; 247 | 58 -> 108; 248 | 111 [ label="Endos"]; 249 | 60 -> 111; 250 | 62 -> 34; 251 | 64 -> 63; 252 | 64 -> 87; 253 | 70 -> 69; 254 | 71 -> 119; 255 | 83 [ label="Folds"]; 256 | 72 -> 83; 257 | 84 [ label="Unfolds"]; 258 | 72 -> 84; 259 | 74 [ label="Finger trees"]; 260 | 73 -> 74; 261 | 80 [ label="Diagram Envelopes"]; 262 | 73 -> 80; 263 | 75 -> 74; 264 | 75 -> 87; 265 | 76 -> 72; 266 | 77 [ label="Traversals"]; 267 | 76 -> 77; 268 | 78 [ label="Maps"]; 269 | 76 -> 78; 270 | 79 [ label="FoldMaps"]; 271 | 76 -> 79; 272 | 77 -> 28; 273 | 78 -> 27; 274 | 79 -> 26; 275 | 85 -> 86; 276 | 86 -> 68; 277 | 88 -> 54; 278 | 89 -> 32; 279 | 92 [ label="There and back again"]; 280 | 91 -> 92; 281 | 93 [ label="TESTING"]; 282 | 94 [ label="Property tests"]; 283 | 93 -> 94; 284 | 94 -> 42; 285 | 94 -> 85; 286 | 94 -> 92; 287 | 96 [ label="Maybe"]; 288 | 96 -> 95; 289 | 97 -> 96; 290 | 98 [ label="Either"]; 291 | 97 -> 98; 292 | 99 [ label="Lists"]; 293 | 97 -> 99; 294 | 98 -> 95; 295 | 100 -> 96; 296 | 100 -> 98; 297 | 100 -> 99; 298 | 104 [ label="Existentializing"]; 299 | 104 -> 107; 300 | 104 -> 108; 301 | 105 -> 104; 302 | 106 [ label="Forall"]; 303 | 105 -> 106; 304 | 109 -> 27; 305 | 109 -> 28; 306 | 109 -> 29; 307 | 110 -> 111; 308 | 112 [ label="Aps"]; 309 | 110 -> 112; 310 | 113 -> 61; 311 | 114 -> 71; 312 | 116 -> 53; 313 | 116 -> 55; 314 | 118 [ label="Only local coherence"]; 315 | 117 -> 118; 316 | 119 -> 30; 317 | -------------------------------------------------------------------------------- /test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isovector/functional-design-patterns/30aad817390994a3092406f1ebd591f444164e8d/test.pdf --------------------------------------------------------------------------------