This file contains 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
const fl = require('fantasy-land') | |
//- Textbook rose tree. | |
//+ type RoseTree a = { value :: a, children :: [RoseTree a] } | |
function RoseTree(value, children) { | |
if (this.constructor !== RoseTree) | |
return new RoseTree(value, children) | |
Object.assign(this, { value, children }) | |
} |
This file contains 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
const fl = require('fantasy-land') | |
//- Lazy holds a vaue in a thunk, effectively delaying | |
//- evaluation until required. This is useful when we're | |
//- in a situation with either very large data set or | |
//- cyclical data. | |
//@ make stack-safe. | |
//> type Lazy a = Unit -> a | |
function Lazy(run) { |
This file contains 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
const { Left, Right } = require('fantasy-eithers') | |
const daggy = require('daggy') | |
Function.prototype.map = function (f) { | |
return x => f(this(x)) | |
} | |
//- Where everything changes... | |
const login = user => | |
user.name == 'Tom' |
This file contains 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
const Day = ({ get, left, right }) => { | |
const map = f => Day ({ | |
get: f (extract()), | |
left, right | |
}) | |
const extend = f => | |
Day ({ | |
get: (left, right) => f (Day ({ get, left, right })), |
This file contains 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 DataKinds #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE UnsaturatedTypeFamilies #-} | |
import GHC.TypeLits | |
import Prelude hiding (Functor, Semigroup) | |
type Main = (Fizz <> Buzz) <$> (0 `To` 100) |
This file contains 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
#!/usr/bin/env cabal | |
{- cabal: | |
build-depends: base, containers, lens | |
-} | |
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE ImportQualifiedPost #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE TemplateHaskell #-} |
This file contains 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
-- ## An Elm-entary visualisation | |
-- by _Tom Harding_ | |
module Main exposing (..) | |
-- This project uses a few dependencies. To anyone who's written any | |
-- amount of Elm before, the only stranger is `AnimationFrame`, from | |
-- the `elm-lang/animation-frame` package. This lets us subscribe to | |
-- the browser's RAF API. Everything else should be fairly obvious: | |
-- `Html` / `Svg` for our view, `Http` / `Json.Decode` for the AJAX |
This file contains 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 Main (main, zip, zipRecord, class ZipRowList) where | |
-- | After Tuesday's experiments, let's move onto a slightly more | |
-- | interesting example. Last time, I confess, I cheated a bit to | |
-- | avoid getting too deep into RowToList stuff. Today, I'm not | |
-- | going to cheat, and get riiiight into it. When we're thirty lines | |
-- | in, don't say you weren't warned! | |
import Prelude (($), discard, Unit) | |
import Control.Monad.Eff (Eff) |
This file contains 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 DeriveGeneric #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
-- | Nothing very serious. | |
-- | |
-- >>> 5 Years | |
-- Years 5 | |
-- |
This file contains 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 MapRecordWithComments where | |
-- | Type-level Tomfoolery. A million thankyous to @kcsongor and his | |
-- | unparallelled patience with me while I try to figure this stuff | |
-- | out. | |
import Prelude (($), (+), (<>), discard, show) | |
import Control.Monad.Eff (Eff) | |
import Control.Monad.Eff.Console (CONSOLE, log) |
NewerOlder