Skip to content

Instantly share code, notes, and snippets.

View dgendill's full-sized avatar

Dominick Gendill dgendill

View GitHub Profile
@dgendill
dgendill / javaScriptObjectDiff.js
Created November 24, 2017 19:44
JavaScript Object Diff
// Some initial work on an object differ.
var difference = Delta(
{
a:{m:1},
c:22
},
{
a:{n:1},
b:7
-- | A dystopian phone system that punishes users who
-- | call the business when it is not open. Calls outside of
-- | business hours are put into a call queue that will never
-- | be answered.
module Main where
import Prelude
import Control.Monad.Eff (Eff)
@dgendill
dgendill / RecursionSchemesExample.purs
Created July 2, 2017 22:55
Factorial Recursion Schemes
module RecursionSchemesExample where
import Prelude
import Control.Monad.Free (Free, liftF)
import Data.Foldable (foldMap)
import Data.Functor.Nu (Nu)
import Data.List (List, catMaybes, null)
import Data.Tuple (Tuple(..))
import Matryoshka as M
@dgendill
dgendill / fixpoint.md
Created June 22, 2017 20:49
Using Purescript Lazy Fixpoint and Lazy

Using Purescript Lazy Fixpoint and Lazy

-- Fibinachi using fixpoint and lazy
lazyFib :: Int -> Lazy Int
lazyFib x
  | x < 2 = defer \_ -> 1
  | otherwise = defer \_ -> (force $ (lazyFib (x-1))) + (force $ (lazyFib (x-2)))

fixFib :: (Int -&gt; Int)
@dgendill
dgendill / purescript-local-documentation.md
Last active April 16, 2017 16:04
Local Documentation In PureScript 0.10.x

Generating Local Documentation In PureScript 0.10.x

Note: It's probably easier to run a local installation of pursuit.


If pulp docs --with-dependencies or psc-docs isn't working for you, this one-liner may be helpful to generate documentation. Run the following command in your project root, and you should get a set of .md files in the docs directory along with a single index.html file (You'll need to install pandoc).

@dgendill
dgendill / eventSource.png
Last active January 9, 2024 21:54
A list of halogen questions and answers
eventSource.png
@dgendill
dgendill / Main.purs
Created March 26, 2017 22:39
Getting truely random numbers from RANDOM.org in PureScript
module Main where
-- bower install
-- "purescript-prelude": "^2.5.0"
-- "purescript-console": "^2.0.0"
-- "purescript-affjax": "^3.0.2"
import Prelude
import Control.Monad.Aff (launchAff)
import Control.Monad.Aff.Console (log)
@dgendill
dgendill / MultipleConsumerCoroutine.purs
Last active March 11, 2017 03:15
Multiple Aff Consumers Connected to a Producer
module MultipleConsumerCoroutine where
import Prelude
import Data.List as List
import Data.List.NonEmpty as NEList
import Control.Coroutine (Consumer, Producer, Transformer, await, connect, emit, joinConsumers, runProcess, transform, transformConsumer)
import Control.Monad.Aff (Aff, launchAff)
import Control.Monad.Aff.Console (log, CONSOLE)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
@dgendill
dgendill / Main.purs
Created March 4, 2017 21:18
Using PureScript's IsForeign class to parse a Point type from a String
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
import Control.Monad.Except (runExcept, throwError)
import Data.Array (head, last, length)
import Data.Either (Either(Right, Left))
import Data.Foldable (traverse_)
import Data.Foreign (F, ForeignError(..), readString, toForeign)
@dgendill
dgendill / Main.purs
Created March 4, 2017 17:37
How to cancel an Aff
module Main where
import Prelude
import Data.Either (either)
import Control.Monad.Aff (Aff, attempt, cancel, forkAff, later', launchAff)
import Control.Monad.Aff.Console (CONSOLE, log, logShow)
import Control.Monad.Eff.Exception (error)
getUpdate :: forall e. Aff (console :: CONSOLE | e) String
getUpdate = do