After listening to the latest Magic Read-along episode "You should watch this" (which you should go listen to now) I got
caught up thinking about Brian's idea of an Endomorphism version of Kleisli composition for use with Redux,
it's actually a very similar model to what I'm using in my event
framework for event listeners so I figured I'd try to formalize the pattern and recognize
some of the concepts involved. IIRC Brian
described the idea of a Redux-reducer, which is usually of type s -> Action -> s, it takes a state and an action and returns
a new state. He then re-arranged
the arguments to Action -> s -> s. He then recognized this as Action -> Endo s (an Endo-morphism is just any function
from one type to itself: a -> a).
He would take his list of reducers and partially apply them with the Action, yielding a list of type Endo s where s
The following are appendices from Optics By Example, a comprehensive guide to optics from beginner to advanced! If you like the content below, there's plenty more where that came from; pick up the book!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Today we'll be looking into Kmett's | |
| [adjunctions](http://hackage.haskell.org/package/adjunctions) library, | |
| particularly the meat of the library in Data.Functor.Adjunction. | |
| This post is a literate haskell file, which means you can load it right up in | |
| ghci and play around with it! Like any good haskell file we need half a dozen | |
| language pragmas and imports before we get started. | |
| > {-# language DeriveFunctor #-} | |
| > {-# language TypeFamilies #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def factorial(n): | |
| if n == 0: return 1 | |
| else: return factorial(n-1) * n | |
| def tail_factorial(n, accumulator=1): | |
| if n == 0: return accumulator | |
| else: return tail_factorial(n-1, accumulator * n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| module BFS where | |
| import Control.Applicative | |
| import Control.Monad.Logic | |
| import Control.Monad.Reader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| We're going to take a look at an alternative way to define a Zipper Comonad | |
| over a data type. Typically one would define a Zipper Comonad by defining a new | |
| datatype which represents the Zipper; then implementing `duplicate` and | |
| `extract` for it. `extract` is typically straightforward to write, but I've had | |
| some serious trouble writing `duplicate` for some more complex data-types like | |
| trees. | |
| We're looking at a different way of building a zipper, The advantages of this | |
| method are that we can build it up out of smaller instances piece by piece. | |
| Each piece is a easier to write, and we also gain several utility functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Folds.Filtering where | |
| import Control.Lens | |
| data Card = | |
| Card { _name :: String | |
| , _aura :: Aura | |
| , _holo :: Bool -- Is the card holographic | |
| , _moves :: [Move] | |
| } deriving (Show, Eq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE DeriveTraversable #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| module Recurser where | |
| import Control.Lens | |
| import Data.Monoid | |
| import Data.Foldable | |
| import Data.Functor.Contravariant |
Generating BQ schema from google sheet header row
To generate a new schema:
-
Copy the ID header row from your google sheet
-
pbpaste | python make_schema.py -
There's your BQ schema!
-
Add a new dataset to bigquery
-
Use your spreadsheet link as the file location
NewerOlder