Skip to content

Instantly share code, notes, and snippets.

module CSS.Cursor where
import Prelude
import CSS (CSS)
import CSS.Property (class Val, Value)
import CSS.String (fromString)
import CSS.Stylesheet (key)
newtype Cursor = Cursor Value
@cscalfani
cscalfani / BookCover.purs
Last active November 10, 2020 17:42
Book Cover for Halogen App
module Image.BookCover where
bookCover :: String
bookCover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAFLCAIAAAC2j8WeAAAGOmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iCiAgICB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iCiAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgZXhpZjpDb2xvclNwYWNlPSIxIgogICBleGlmOlBpeGVsWERpbWVuc2lvbj0iMjU2IgogICBleGlmOlBpeGVsWURpbWVuc2lvbj0iMzMxIgogICBwaG90b3Nob3A6Q29sb3JNb2RlPSIzIgogICB
module ChalkStyles
(
Style
, black
, red
, green
, yellow
, blue
, magenta
, cyan
module ChalkStyles where
newtype Style = Style String
black :: Style
black = Style "black"
red :: Style
red = Style "red"
const http = require("http");
const hostname = "0.0.0.0";
const port = 3000;
const server = http.createServer((req, res) => {
console.log(`\n${req.method} ${req.url}`);
console.log(req.headers);
const reverseArray = a => {
module Main where
import Prelude
import Control.Monad.Except.Trans (ExceptT, runExceptT, throwError, catchError)
import Control.Monad.State.Trans (StateT, runStateT, get, put)
import Control.Monad.Writer.Trans (class MonadTell, WriterT, runWriterT, tell)
import Data.Either (Either)
import Data.Tuple (Tuple)
import Effect.Console as Console
@cscalfani
cscalfani / ElmVSPurescript.pdf
Last active August 27, 2021 15:03
Here are the slides to the first lecture in my training class I'm running at work for the Elm programmers to help them transition to PureScript.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

How to Think About Monads 2

How to Think about Monads, starts with composition of pure functions and quickly transitioned to composition of pure functions with side-effects. If you haven't read it yet, please do. This continues where that left off.

By the end of that article, we created specialized composition functions that were equivalent to the Monadic bind.

From that article we can conclude that Monadic computations have the following properties:

  1. Functions are executed sequentially
  2. Optionally, control-flow can be short-circuited

foldr written the normal way and as the dual of unfoldr

The following code was inspired by Kwang's Haskell Blog post titled unfold and fold.

module Main where

import Prelude hiding (foldr)
import Data.Function ((&))