Skip to content

Instantly share code, notes, and snippets.

@JordanMartinez
JordanMartinez / Main.purs
Created September 22, 2020 19:23
Lefts function for Array
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
import Data.Foldable (foldl)
import Data.Either (Either(..), either)
import Data.Array (snoc)
@JordanMartinez
JordanMartinez / Main.purs
Last active September 19, 2020 03:59
Simple Math parser via 'precedence climbing' approach
module Main where
import Prelude hiding (between)
import Control.Alt ((<|>))
import Control.Lazy (defer, fix)
import Data.Either (Either(..), either)
import Data.Foldable (foldMap, oneOf)
import Data.FoldableWithIndex (forWithIndex_)
import Data.Int (fromString)
@JordanMartinez
JordanMartinez / Main.purs
Created September 18, 2020 13:39
Writing a parser for simple math computations
module Main where
import Prelude
import Control.Lazy (fix)
import Data.Either (Either(..), either)
import Data.Foldable (foldMap, oneOf)
import Data.Int (fromString)
import Data.Maybe (Maybe(..))
import Data.String.CodeUnits (drop, take)
@JordanMartinez
JordanMartinez / Main.purs
Created September 8, 2020 01:58
ArrayZipper's smallest Extend implementation
module Main where
import Prelude
import Control.Comonad (class Comonad)
import Control.Extend (class Extend)
import Control.Monad.Gen (chooseInt)
import Data.Array (length, mapWithIndex, slice, unsafeIndex)
import Effect (Effect)
import Effect.Aff (launchAff_)
@JordanMartinez
JordanMartinez / Main.purs
Created August 22, 2020 14:19
f-o-a-m/purescript-optparse Syntax Guide
module Learn.OptParse where
import Prelude
import Data.Foldable (fold)
import Effect (Effect)
import Effect.Console (logShow)
import ExitCodes (ExitCode(..))
import Options.Applicative (Parser, execParser, failureCode, flag, footer, fullDesc, header, help, helper, info, int, long, metavar, number, option, progDesc, short, showDefault, showDefaultWith, str, strOption, switch, value)
@JordanMartinez
JordanMartinez / Main.purs
Created July 25, 2020 04:11
MemoizeFibonacci issue
module Main where
import Prelude
import Data.Function.Memoize (memoize)
import Data.Interpolate (i)
import Debug.Trace (spy)
import Effect (Effect)
import Effect.Class.Console (log)
main :: Effect Unit
@JordanMartinez
JordanMartinez / Main.purs
Last active May 30, 2020 17:15
Hooks does not remove component when disposed
module Main where
import Prelude
import Data.Maybe (Maybe(..))
import Data.Monoid (power)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Aff (Aff, Milliseconds(..), delay)
@JordanMartinez
JordanMartinez / Main.purs
Last active May 30, 2020 17:17
Halogen removes component when disposed
module Main where
import Prelude
import Data.Maybe (Maybe(..))
import Data.Monoid (power)
import Effect (Effect)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Effect.Aff (Aff, Milliseconds(..), delay)
@JordanMartinez
JordanMartinez / Economical Benefits of Functional Programming.md
Last active May 9, 2020 02:40
Economic Benefits of Functional Programming Languages

A Translation of the Economical Benefits of Functional Programming Languages

Name of Video: Michael Snoyman- Economic Argument for Functional Programming- λC 20 Global Edition

Source: https://youtu.be/n7QETok5hYI?t=3195

What developers say What managers should hear
Allows us to write more "declarative" code
  • Spend more time on adding new features or other enhancements due to spending less time on code review
  • Add new features or make needed changes faster and without adding new flaws to current code
Uses immutable data by default Wake up engineers at 3am less often so they can fix bugs:Reduce the risk of race conditionsReduce the risk of business logic errors
@JordanMartinez
JordanMartinez / Explanation.md
Last active March 20, 2020 02:00
How to Wrap HTML elements using Halogen's HTML DSL

This has come up enough that I'm writing a guide for someone else to create these things. If you have a need, then you're likely motivated enough to get this going. This stuff is straight forward and can be inferred by looking at the source code. It is, however, a bit tedious.

How to Wrap HTML in Halogen's HTML DSL

HTML has 3 parts to it: the tag, the tag's attributes/properties/events, and whether or not it has children. In other words:

<elementName attribute="value" property="value" onevent="doStuff();">
  <child></child>
  <child></child>