Skip to content

Instantly share code, notes, and snippets.

View TikhonJelvis's full-sized avatar

Tikhon Jelvis TikhonJelvis

View GitHub Profile
(defun org-read-add-default-time
(&optional with-time to-time from-string prompt
default-time default-input inactive)
"Filters the inputs to `org-read-date', setting the current time
as the default input if one was not already specified."
(let ((new-default (or default-input (format-time-string "%H:%M"))))
(list with-time to-time from-string prompt
default-time new-default inactive)))
(define-advice org-read-date (:filter-args (args) default-current-time)
@TikhonJelvis
TikhonJelvis / haskell-big-data-mode.el
Created April 7, 2022 20:52
A minor mode for working with big data in Haskell
(defface haskell-big-keyword-face
'((t (:inherit haskell-keyword-face :weight bold :height 2.0)))
"BIG keywords.")
(defvar haskell-font-lock-big-data-keywords
'(("^data\\>" 0 'font-lock-big-keyword-face t)))
(define-minor-mode haskell-big-data-mode
"Minor mode for working with BIG data in Haskell. Adds a font
lock keyword for rendering 'data' at twice the normal font size."
:group haskell-big-data-mode
@TikhonJelvis
TikhonJelvis / haskell-to-do.hs
Created February 21, 2022 20:10
Haskell to-do list with BlockArguments and Writer
list :: [Task Text]
list = to do
(□) "milk"
(□) "eggs"
(✓) "orange juice"
data Task a = Done a | Todo a deriving (Show)
to = execWriter
@TikhonJelvis
TikhonJelvis / cabal-schema.json
Created August 30, 2021 00:41
A nowhere-near complete or correct JSON Schema for Cabal package descriptions
{
"title": "Cabal file",
"type": "object",
"properties": {
"license-files": {
"description": "One or more files containing the precise copyright license for the package.",
"items": {
"type": "string"
},
"type": "array"
@TikhonJelvis
TikhonJelvis / Internals.hs.out
Created July 10, 2018 21:24
Internals.hs.out
This file has been truncated, but you can view the full file.
{-# LANGUAGE DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses,
CPP #-}
#if __GLASGOW_HASKELL__ >= 708
{-# LANGUAGE RoleAnnotations #-}
#endif
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
-- Module : Data.Array.IO.Internal
@TikhonJelvis
TikhonJelvis / Control.hs-with-include.out
Created July 10, 2018 21:17
Control.hs.out with and without #include directive
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP
, NoImplicitPrelude
, ScopedTypeVariables
, BangPatterns
#-}
module GHC.Event.Control
module(GHC.Event.Control
(-- * Managing the IO manager
@TikhonJelvis
TikhonJelvis / shell.nix
Last active October 18, 2020 03:24
A simple shell.nix for a Haskell project that calls cabal2nix for you.
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default" }:
let
inherit (nixpkgs) pkgs;
# Build a default.nix file from our .cabal file:
here = ./.;
project = pkgs.stdenv.mkDerivation ({
name = "default.nix";
@TikhonJelvis
TikhonJelvis / reverse-state.hs
Created March 31, 2015 01:14
An implementation of the reverse state monad with the extra newtype wrapping and unwrapping needed to actually make it work:
newtype RState s a = RState (s -> (a, s))
-- takes initial state s and outputs both a result and a new state
runRState :: RState s a -> s -> (a, s)
runRState (RState f) start = f start
instance Monad (RState s) where
return x = RState $ \ s -> (x, s)
RState step1 >>= step2 = RState $ \ start ->
let (resultA, final) = step1 intermediate
@TikhonJelvis
TikhonJelvis / epage
Created May 10, 2014 20:30
A little pager script I wrote that calls out to emacsclient.
#! /usr/bin/env runhaskell
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Functor ((<$))
import System.Directory (removeFile)
import System.Environment (getArgs)
import System.Process (runCommand)
import Text.Printf (printf)
@TikhonJelvis
TikhonJelvis / viz.hs
Last active September 22, 2016 06:05
Generating graphs for my Quora answer
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
import qualified Data.Graph.Inductive as Graph
import Data.Graph.Inductive (Gr, match, matchAny)
import Data.String.Interpolation (str)
complex :: Gr () ()
complex = Graph.mkGraph nodes edges
where nodes = [(x, ()) | x <- [1..10]]