Skip to content

Instantly share code, notes, and snippets.

Lazy and Strict Maps in Haskell

import           Control.Concurrent

import           Data.Map.Lazy                 as LM
import           Data.Map.Strict               as SM

import System.IO.Unsafe
import functools
import types
def attrfunc(func=None, **attrs):
if not func:
return functools.partial(attrfunc, **attrs)
return AttrFunc(func, **attrs)
class AttrFunc:
def __init__(self, func, **attrs):
# switch_0.py
# Runs actions/values as they are found
class FirstMatchFound(Exception):
pass
class InvalidResultTypeError(Exception):
pass
"""
Use this file to write your solution for the Summer Code Jam 2020 Qualifier.
Important notes for submission:
- Do not change the names of the two classes included below. The test suite we
will use to test your submission relies on existence these two classes.
- You can leave the `ArticleField` class as-is if you do not wish to tackle the
advanced requirements.
@purefunctor
purefunctor / init.vim
Created November 22, 2020 06:41
Activate Pipenv or Poetry environments when using `pyright` in `nvim-lspconfig`
let g:old_path = ""
function CheckPoetry()
let s:poetry = system("poetry env list --full-path")
if v:shell_error
return ""
else
return substitute(s:poetry, " (Activated)\n", "", "") . "/bin:"
endif
@purefunctor
purefunctor / config.el
Last active December 24, 2020 16:55
Doom Emacs bodge for zsh/oh-my-zsh and emacs-libvterm
;; Terrible code, I know
;; Reference: https://github.com/akermu/emacs-libvterm/issues/24
(after! vterm (progn (defun vterm--kill-vterm-buffer-and-window (process _)
"Kill buffer and window on vterm process termination."
(when (not (process-live-p process))
(let ((buf (process-buffer process)))
(when (buffer-live-p buf)
(with-current-buffer buf
(kill-buffer)
(ignore-errors (delete-window))

Keybase proof

I hereby claim:

  • I am purefunctor on github.
  • I am purefunctor (https://keybase.io/purefunctor) on keybase.
  • I have a public key ASCMMHUzQ7cIe7K2p0_1VjvWVyy4hUo1ky916apWPEJh3wo

To claim this, I am signing this object:

from typing import Generic, overload, Literal, TypeVar, Union
_Head = TypeVar("_Head")
_Tail = TypeVar("_Tail")
class HeadTuple(Generic[_Head, _Tail]):
def __init__(self, head: _Head, *tail: _Tail) -> None:
self._head = head
@purefunctor
purefunctor / Main.purs
Created July 27, 2021 03:50
PureScript `waitFor` combinator for Aff
module Main where
import Prelude
import Data.Either (Either)
import Data.Int (round)
import Effect (Effect)
import Effect.Aff (Aff, Milliseconds(..), attempt, delay, error, forkAff, joinFiber, killFiber, launchAff_)
import Effect.Class (liftEffect)
import Effect.Class.Console (logShow)
@purefunctor
purefunctor / Main.purs
Created August 15, 2021 19:54
PureScript Module Shadowing
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
data Effect_Console = Effect_Console
main :: Effect Unit