Skip to content

Instantly share code, notes, and snippets.

@JulianBirch
JulianBirch / Day4.hs
Last active Dec 28, 2019
Solving Advent of Code 2019 Day4 using recursion schemes and the free list monad
View Day4.hs
{-# LANGUAGE FlexibleContexts, FlexibleInstances, RankNTypes, InstanceSigs, TypeApplications, ScopedTypeVariables, MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving, DerivingVia, DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies, GADTs #-}
{-# LANGUAGE AllowAmbiguousTypes, UndecidableInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Day4 where
import Data.Functor.Foldable(hylo)
View GeoControl.txt
Good morning, oregenes and guardians
Stills and mother-losing grits
This a ten-ringer named 'Baster coming
And he's here to end your world,
Start a tale that will soon be classic
About a woman you already no
No four-ringer she but rather the saviour of your species
Geo Control (Are you ready?)
Our story begins in the fulcrum
View Day19.hs
module Day19 where
import Data.Maybe (maybe)
import Data.List (find, findIndex, unfoldr)
import Data.Char (isLetter)
day19text :: IO [[Char]] -- We could use a better data structure, but the code only gets run once
day19text = lines <$> readFile "C:\\Users\\me\\advent\\day19.txt"
isWire :: Char -> Bool
View Modern FP with mtl.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
View ClojureScript
Exception in thread "main" java.lang.AbstractMethodError: cljsbuild.compiler.SourcePaths._find_sources(Ljava/lang/Object;)Ljava/lang/Object;, compiling:(/tmp/form-init5931832452504796267.clj:1:73)
at clojure.lang.Compiler.load(Compiler.java:7239)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
at clojure.main$null_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
View Yorgey4.hs
{-# OPTIONS_GHC -Wall #-}
import Data.List
fun1 :: [Integer] -> Integer
fun1 [] = 1
fun1 (x:xs)
| even x = (x - 2) * fun1 xs
| otherwise = fun1 xs
@JulianBirch
JulianBirch / markov.hs
Last active Aug 29, 2015
Revised version of Kris Jenkin's Markov Generator
View markov.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE RankNTypes #-}
module Main where
-- Lots more imports
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import System.Random
View yorgey3.hs
{-# OPTIONS_GHC -Wall #-}
module Golf where
import qualified Data.Map.Strict as M
import Data.List as L
import Data.Maybe
skip :: [a] -> Int -> [a]
skip l n = case drop n l of
(x:xs) -> x : skip xs n
@JulianBirch
JulianBirch / lessc.clj
Created Dec 24, 2013
lessc watcher in Clojure
View lessc.clj
(ns lessc
(:require [pro.juxt.dirwatch :refer (watch-dir)]
[clojure.java.io :refer (file)]
[spyscope.core]
[clojure.core.async :as a]))
(defn run-less []
(println "Running LESS")
(doto
(ProcessBuilder. ["lessc" "resources/bootstrap/assets/mybootstrap.less" "resources/public/s.css"])
View X.md

poppea

A couple of macros that do useful, general things.

Usage

The easiest way to use Poppea in your project is via Clojars.

Leiningen:

You can’t perform that action at this time.