Skip to content

Instantly share code, notes, and snippets.

View cideM's full-sized avatar

Florian Beeres cideM

View GitHub Profile
@cideM
cideM / foo.hs
Last active January 4, 2019 18:58
Understanding state monad in relation to replicateM
#!/usr/bin/env stack
{-
stack
script
--resolver lts-12.20
--package mtl,text,monad-loops
-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Control.Monad as M
@cideM
cideM / unliftio.md
Created May 5, 2019 15:45
Understanding `unliftio`

Understanding unliftio

Try to understand the ReaderT instance.

withRunInIO inner =
    ReaderT $ \r ->
    withRunInIO $ \run ->
    inner (run . flip runReaderT r)
@cideM
cideM / askUnliftIO.hs
Last active June 11, 2019 16:04
File that accompanies my blog post about unliftio-core
#!/usr/bin/env stack
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-
stack
script
--resolver lts-13.16
--package transformers
-}
@cideM
cideM / breadth_first.lhs
Created March 6, 2020 18:43
Working through interesting code for breadth first traversal from a blog post
[Link to Breadth First series](https://doisinkidney.com/posts/2018-03-17-rose-trees-breadth-first.html)
> data Tree a = Node
> { root :: a
> , forest :: Forest a
> }
>
> type Forest a = [Tree a]
> breadthFirst :: Forest a -> [a]
# .config/nixpkgs/overlays/custompkgs.nix
self: super: {
userPkgs = self.buildEnv {
name = "user-packages";
pathsToLink = [ "/share" "/bin" ];
paths = with self.pkgs; [
firefox-devedition-bin
alacritty
tmux
lazygit
# .config/nixpkgs/overlays/neovim.nix
self: super: {
neovim-unwrapped = (super.neovim-unwrapped.override { lua = self.luajit; }).overrideAttrs(oldAttrs: {
cmakeFlags = oldAttrs.cmakeFlags ++ [ "-DMIN_LOG_LEVEL=0" ];
version = "master";
src = builtins.fetchGit {
url = https://github.com/neovim/neovim.git;
};
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@cideM
cideM / shell.nix
Created May 16, 2020 11:15
Trying to build ocaml-lsp
let
pkgs = import <nixpkgs> {};
cinaps = pkgs.ocaml-ng.ocamlPackages_4_09.buildDunePackage rec {
pname = "cinaps";
version = "latest";
src = pkgs.fetchFromGitHub {
owner = "ocaml-ppx";
repo = "cinaps";
rev = "e3183c4733d0577d4d54211cafa4a52dfe5dd235";
@cideM
cideM / url_encode.sh
Created June 11, 2020 19:14
URL Encode a String with POSIX Shell
#!/bin/sh
# https://en.wikipedia.org/wiki/Percent-encoding
# https://stackoverflow.com/questions/38015239/url-encoding-a-string-in-shell-script-in-a-portable-way
# https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable
# "The variable LANGUAGE is ignored if the locale is set to ‘C’"
# Not entirely sure why this is done to be honest
LANG=C;
@cideM
cideM / gist:f5458f8b7aa95a5fa75970e0c8a7457b
Last active September 8, 2020 14:13
So you want diagnostics in Neovim
Maybe I'll turn this into a blog post at some point. Right now I just want some
clarity and peace of mind, so I'll dump my thoughts into this Gist.
Diagnostics information in Neovim can either come from one or several related
files, or the entire project. An example of the former would be the module
you're currently working on and all its dependencies. Regardless of which type
of diagnostics you prefer, I think it's safe to assume that you want to be able
to use both. Sometimes a change compiles in the scope of a single module but
not in the context of the entire project, since usages of the changed module
need to update their interface definitions or something like that.