Skip to content

Instantly share code, notes, and snippets.

View dgendill's full-sized avatar

Dominick Gendill dgendill

View GitHub Profile
@dgendill
dgendill / eventSource.png
Last active January 9, 2024 21:54
A list of halogen questions and answers
eventSource.png
@dgendill
dgendill / Main.purs
Last active January 4, 2018 16:51
Example of the State and Either Monad used in Purescript
-- http://try.purescript.org/?gist=8edc7ff9f3f3bcd347959e9cd2f07376
module Main where
import Prelude
import Data.Identity
import Control.Monad.State
import Control.Monad.Except
import Control.Monad.Eff.Console (log, logShow)
type FirstName = String
@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 / Main.purs
Last active May 11, 2017 13:20
Example using the Writer monad's listen, past, and listens functions in PureScript. Also exercise 11.6 part 2
-- http://try.purescript.org/?gist=45bfcac3cf142daaa165323ae45069cd
module Main where
import Prelude
import Control.Monad.Writer(Writer(..), tell, listen, listens, pass, runWriter)
import Data.Array(tail, head, drop, length)
import Data.String(joinWith)
import Data.Tuple(fst, snd, Tuple(..))
import Math (remainder, (%))
import Control.Monad.Eff.Console (log, logShow)
@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 / 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)