Skip to content

Instantly share code, notes, and snippets.

View pete-murphy's full-sized avatar

Pete Murphy pete-murphy

View GitHub Profile
@pete-murphy
pete-murphy / Main.purs
Created February 8, 2021 02:57
Testing hash-routing example in TryPureScript
module Main where -- Overwritten by Try PureScript
import Prelude
import Data.Array as Array
import Data.Foldable as Foldable
import Data.Maybe (Maybe(..))
import Data.String as String
import Effect (Effect)
import Effect.Exception as Exception
import React.Basic (JSX)
@pete-murphy
pete-murphy / Main.purs
Last active March 16, 2021 17:43
Using `non`
module Main where
import Prelude
import Data.Lens (non, set)
import Data.Lens.At (at)
import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect.Class.Console (logShow)
import Foreign.Object as Object
@pete-murphy
pete-murphy / Main.purs
Created July 11, 2021 23:04
Attempt to setTitle in Halogen
module Main where -- Overwritten by Try PureScript
import Prelude
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Halogen as H
import Halogen.HTML as HH
import Halogen.Aff as HA
import Halogen.VDom.Driver (runUI)
import fs from "fs"
import { flow, pipe, not } from "fp-ts/function"
import * as Str from "fp-ts/string"
import * as E from "fp-ts/Either"
import * as O from "fp-ts/Option"
import * as RA from "fp-ts/ReadonlyArray"
import * as D from "io-ts/Decoder"
const lines = (str: string): ReadonlyArray<string> => str.split("\n")
@pete-murphy
pete-murphy / Main.purs
Created July 12, 2021 18:45
Set title and meta tag from Halogen
module Main where -- Overwritten by Try PureScript
import Prelude
import Data.Foldable as Foldable
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Halogen as H
import Halogen.HTML as HH
import Halogen.Aff as HA
@pete-murphy
pete-murphy / example-usage.ts
Last active December 9, 2021 00:41
Fold in fp-ts
import * as L from "./foldl"
import * as RA from "fp-ts/ReadonlyArray"
import * as RNEA from "fp-ts/ReadonlyNonEmptyArray"
import * as T from "fp-ts/Tree"
import { identity, pipe } from "fp-ts/function"
const sum: L.Fold<number, number> = run =>
run({
step: (x, y) => x + y,
init: 0,
@pete-murphy
pete-murphy / Main.purs
Created August 21, 2021 19:48
Arbitrary for custom ADT
module Main where
import Prelude
import Effect (Effect)
import Effect.Class.Console as Console
import Data.Generic.Rep (class Generic)
import Data.Show.Generic as Show.Generic
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Arbitrary as Arbitrary
import Test.QuickCheck.Gen (Gen)
@pete-murphy
pete-murphy / Main.purs
Last active September 18, 2021 22:59
alaF and foldMap
module Main where
import Prelude
import Data.Foldable (foldMap, sum)
import Data.List (List)
import Data.List.Lazy (replicate, toUnfoldable)
import Data.Monoid.Additive (Additive(..))
import Data.Newtype (alaF)
import Data.Rational (Ratio, (%))
@pete-murphy
pete-murphy / Main.purs
Last active May 11, 2023 21:12
Unify error types in a simple fetch & decode example (PureScript)
module Main where
import Prelude
import Affjax as Affjax
import Affjax.ResponseFormat as ResponseFormat
import Control.Monad.Except (ExceptT(..))
import Control.Monad.Except as Except
import Data.Argonaut as Argonaut
import Effect (Effect)
import Effect.Class as Effect
module Main where
import Prelude
import Control.Alt ((<|>))
import Control.Lazy as Lazy
import Data.Either (Either(..))
import Data.Int as Int
import Data.Maybe (Maybe(..))
import Effect (Effect)