Note: you can copy the file 2-lenses.js below over to repl.it and
play along from home!
A lens in programming, much like a lens in the real world, allows you to focus in on a small part of a larger whole and then do something with or to
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE GeneralisedNewtypeDeriving #-} | |
| module BiblePlan where | |
| import qualified Data.Time as T | |
| import qualified Data.Time.Calendar.WeekDate as WD | |
| import qualified Data.Text as T | |
| import qualified Data.Vector as V | |
| import Text.Printf (printf) |
| #!/bin/bash | |
| # source: http://www.haskell.org/pipermail/haskell-cafe/2011-March/090170.html | |
| sudo rm -rf /Library/Frameworks/GHC.framework | |
| sudo rm -rf /Library/Frameworks/HaskellPlatform.framework | |
| sudo rm -rf /Library/Haskell | |
| rm -rf ~/.cabal | |
| rm -rf ~/.ghc | |
| rm -rf ~/Library/Haskell |
Note: you can copy the file 2-lenses.js below over to repl.it and
play along from home!
A lens in programming, much like a lens in the real world, allows you to focus in on a small part of a larger whole and then do something with or to
| -- This is going to be on Hackage soon! https://github.com/gatlin/surely | |
| {-# LANGUAGE BangPatterns #-} | |
| -- | | |
| -- Module : AI.Surely | |
| -- Copyright : 2012 Gatlin Johnson | |
| -- License : LGPL 3.0 | |
| -- Maintainer : rokenrol@gmail.com | |
| -- Stability : experimental |
| {- cabal: | |
| build-depends: base, repa, repa-algorithms | |
| -} | |
| {- To run: | |
| 1. Install Haskell tools (https://www.haskell.org/ghcup/) | |
| 2. cabal run Main.hs -- +RTS -s -} | |
| module Main where |
| #!/bin/bash | |
| MEDIA_FILE="$1" | |
| if [ -z "$1" ]; then | |
| echo "Please specify a media file as the first argument." | |
| exit 1 | |
| fi | |
| CHROMECAST_IP4_ADDRESS="$2" |
| // inspiration: | |
| // https://www.schoolofhaskell.com/user/bartosz/understanding-algebras | |
| /** | |
| * Higher-kinded Types. | |
| * A higher-kinded type is a type that abstracts over some type that, in turn, | |
| * abstracts over another type. | |
| * | |
| * To support them in TypeScript we have to write a few types first. | |
| */ | |
| declare const Type: unique symbol; |
Or: functor? I 'ardly know 'er!
Monads are difficult to explain without sounding either patronizing or condescending: I would sound patronizing if I came up with some facile analogy and I would be condescending to describe it categorically.
Instead, I'll frame a problem and piece-by-piece solve the problem with what will turn out to be a monad.
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| import Prelude hiding (not,and,log) | |
| import Control.Monad | |
| import Control.Monad.State | |
| import Control.Monad.Free | |
| import Control.Monad.Trans | |
| import Control.Monad.Writer | |
| import qualified Data.Vector.Unboxed as U |
| 'use strict'; | |
| let str = "the quick brown fox jumps over the lazy dog"; | |
| let fw = Array.prototype.map | |
| .call(str, (c) => c === ' ' | |
| ? ' ' | |
| : String.fromCodePoint(c.codePointAt(0) + 0xFEE0)) | |
| .join(''); | |
| console.log(fw); |