Skip to content

Instantly share code, notes, and snippets.

@j1r1k
j1r1k / RenderPath.purs
Last active May 14, 2016 21:43
PureScript by Example: Chapter 9 (Canvas Graphics) exercise 9.4.3
module RenderPath where
-- 3. (Medium) Given the following record type:
-- type Point = { x :: Number, y :: Number }
-- which represents a 2D point, write a function renderPath which strokes a closed path
-- constructed from a number of points:
--
-- renderPath :: forall eff. Context2D ->
-- Array Point ->
-- Eff (canvas :: Canvas | eff) Context2D
@j1r1k
j1r1k / RandomCircle.purs
Last active August 30, 2017 07:34
PureScript by Example: Chapter 9 (Canvas Graphics) exercise 9.8.2
module RandomCircle where
-- 2. (Medium) Use the RANDOM and DOM effects to create an application which renders a circle with
-- random position, color and radius to the canvas when the mouse is clicked.
import Prelude
import Data.Maybe
import Data.Traversable (for)
@j1r1k
j1r1k / Tagged.purs
Last active May 16, 2016 18:44
PureScript by Example: Chapter 10 (The Foreign Function Interface) exercise 10.19.4
module Tagged where
import Prelude
import Data.Either
import Data.Foreign
import Data.Foreign.Class
newtype Tagged a b = Tagged (Either a b)
@j1r1k
j1r1k / Tree.purs
Created May 16, 2016 18:44
PureScript by Example: Chapter 10 (The Foreign Function Interface) exercise 10.19.5
module Tree where
import Prelude
import Control.Alt
import Data.Either
import Data.Foreign
import Data.Foreign.Class
@j1r1k
j1r1k / ParallelConcat.purs
Created May 28, 2016 21:28
PureScript by Example: Chapter 12 (Callback Hell) exercise 12.8.1
module ParallelConcat where
import Prelude (Unit, (<<<), ($), bind)
import Types (Async)
import Control.Monad.Except.Trans (ExceptT, mapExceptT)
import Control.Parallel (inParallel, runParallel)
import Data.Foldable (fold)
@j1r1k
j1r1k / functionalLenses.js
Created March 8, 2018 07:58
Code from a ngParty talk @ 7th Mar 2018
const R = require("ramda");
const data = {
title: "Intro to functional lenses",
author: {
name: "Jiri Marsicek",
email: "jiri.marsicek@gmail.com",
position: {
name: "Software Engineer",