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
| 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 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 DataKinds #-} | |
| {-# LaNgUaGe FlexibleInstances #-} | |
| {-# lAnGuAgE FunctionalDependencies #-} | |
| {-# LaNgUaGe KindSignatures #-} | |
| {-# lAnGuAgE TypeFamilies #-} | |
| {-# LaNgUaGe TypeOperators #-} | |
| {-# lAnGuAgE UndecidableInstances #-} | |
| module Commit where | |
| import Data.Kind (Constraint, Type) |
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 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 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 FlexibleInstances #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| ------------------------------ | |
| -- PROBAT | |
| main :: IO () |
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 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) |
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 Main where | |
| -- | JSON is an incredibly simple format. Even its lists are untyped. | |
| -- | As with all languages, functional programming encourages us to | |
| -- | make a domain-specific language (or DSL) to capture the "ideas" | |
| -- | of the language, which we can then use to talk about its content. | |
| -- | In this little snippet, we'll build a JSON DSL, transform it into | |
| -- | a recursive structure, and then use that result to generate some |
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
| const daggy = require('daggy') | |
| const { uncurryN } = require('wi-jit') | |
| Array.prototype.empty = () => [] | |
| Sum = daggy.tagged('value') | |
| Sum.prototype.concat = function (that) { | |
| return Sum(this.value + that.value) | |
| } |
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
| 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 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
| 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 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
| 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' |
NewerOlder