Skip to content

Instantly share code, notes, and snippets.

View JordanMartinez's full-sized avatar

JordanMartinez

  • USA
View GitHub Profile
@JordanMartinez
JordanMartinez / First.purs
Last active October 25, 2018 02:17
Undo Manager: Zipperless / One-Hole Context version vs Zipper version
-- Zipperless / One-Hole Context
import Data.List (List(..), null, (:))
import Data.Tuple (Tuple(..))
class Invertable change where
invert :: change -> change
class Undoable a change where
applyChange :: a -> change -> a
@JordanMartinez
JordanMartinez / Multi-Caret-Selection-TextContent.purs
Last active November 10, 2018 20:09
Content with multiple carets/selections
module Something where
-- Let's say we have a content type, like a String
type Content = String
{-
Now let's say we want to add a cursor/caret to that data type
so that we can add/remove characters to the String at
the position of that cursor.
@JordanMartinez
JordanMartinez / Problems-it-needs-to-solve.md
Created November 21, 2018 16:35
Philosophy of Text Editor

Problems to solve

Model of Editor

  • a definition for what a docuemnt is
    • Sequence of Paragraphs
      • non-newline-ending-pars
        • PlainText - sequence of strings (paragraphs)
        • RichText - sequence of styled segments
  • newline-ending pars
@JordanMartinez
JordanMartinez / Modern FP with mtl.purs
Last active March 19, 2021 06:55 — forked from ocharles/Modern FP with mtl.hs
Purescript port of the original Haskell "Modern FP with MTL"
module Modern_FP_With_MTL where
import Effect.Console as Console
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Control.Monad.Trans.Class (class MonadTrans, lift)
import Prelude
{-
Since Purescript does not have Haskell's "GeneralizedNewtypeDeriving" language
@JordanMartinez
JordanMartinez / TestOp.purs
Created April 24, 2019 17:50
Tracking down OptParse help text slowdown
module TestOP where
import Prelude
import Data.Array (filter, intercalate)
import Data.Array as Array
import Data.Either (Either(..))
import Data.String (Pattern(..), split)
import Data.String as String
import Effect (Effect)
@JordanMartinez
JordanMartinez / Main.purs
Last active May 12, 2019 03:24
Finalizers not being run?
module Main where
import Prelude
import Data.Const (Const)
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Aff (Aff, Milliseconds(..), delay, launchAff_)
import Effect.Console (log)
import Halogen (liftEffect)
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE GADTs #-}
module Data.Sheaves.Optics where
type a + b = Either a b
@JordanMartinez
JordanMartinez / RebindableDoAdo.purs
Last active July 25, 2019 00:11
Rebinding 'bind' via a let binding in a do notation produces an error, but rebinding 'apply' in a let binding in a ado notation does not
module Syntax.RebindableDoAdo where
import Prelude
import Control.Bind as NormalBind
import Data.Functor as NormalMap
import Control.Apply as NormalApply
-- Given this monad (type class instances are at bottom of file)
data Box a = Box a
@JordanMartinez
JordanMartinez / SeldaExample.purs
Created July 28, 2019 01:17
purescript-selda example using my slightly updated Spago-based fork
module SeldaExample where
import Prelude
import Control.Monad.Except (ExceptT, runExceptT, throwError)
import Control.Monad.Reader (ReaderT, runReaderT)
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.Traversable (for_)
import Database.PostgreSQL (Connection, PGError, PoolConfiguration, Query(..), Row0(..), execute, newPool, withConnection)
@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>