Skip to content

Instantly share code, notes, and snippets.

(* Functors and modular implicits
* opam switch 4.02.0+modular-implicits
* eval `opam config env`
*)
module type FUNCTOR = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
let map {F : FUNCTOR} = F.map
@dalaing
dalaing / Demo.hs
Created January 18, 2018 12:18
Bound Demo
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE StandaloneDeriving #-}
module Demo where
@nurpax
nurpax / char-rnn.hs
Last active November 9, 2017 15:50
Some char-rnn generated Haskell based on training with the GHC HEAD source code
-- buildPatSynDetails, so this is a mempty, even the type
-- we generate the same location here.
hsConDeclDetails _ = pprPanic "tcLHsBindsCtOrigin" (ppr val_val_binds)
--------------------
zonkForeignCall :: FlexibleInfo -> CoreBind
-> Maybe FreeVars -- True <=> supplied EndBinds
-> RecFlag
-> Cts -> ForeignOpt Id
@taktoa
taktoa / mrkgnaow-xmonad.nix
Created September 25, 2017 15:30
Example of using `callCabal2nix` to set up xmonad with a cabalized configuration
{ pkgs }:
{
services.windowManager.xmonad = {
enable = true;
haskellPackages = pkgs.haskellPackages.override {
overrides = self: super: {
# /path/to/mrkgnaow-xmonad is a path that contains `mrkgnaow-xmonad.cabal`
# you can also put an invocation of `fetchgit` or `fetchFromGitHub` there.
mrkgnaow-xmonad = self.callCabal2nix "mrkgnaow-xmonad" /path/to/mrkgnaow-xmonad {};
@3noch
3noch / .ghci
Last active October 29, 2018 09:49
Reflex-DOM Auto Reload Development with ghcid
:set prompt "> "
:set -isrc
:load Main
@thoughtpolice
thoughtpolice / RegAlloc1.hs
Last active July 26, 2022 13:49
Simple register allocation, see "Essentials of Compilation" for more https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
module RegAlloc1
( -- * Types
Var
@Icelandjack
Icelandjack / RecordPatternDictionary.markdown
Last active August 7, 2017 09:09
Open Monad dictionary with record pattern synonym (and as patterns)
{-# Language PatternSynonyms #-}
{-# Language ViewPatterns    #-}

data DMonad m = DMonad
  (forall a.   a -> m a)
  (forall a b. m a -> (a -> m b) -> m b)
  (forall a.   String -> m a)

pattern Open :: (forall a. a -&gt; [a]) -&gt; (forall a a'. [a] -&gt; (a -&gt; [a']) -&gt; [a']) -&gt; (forall a. String -&gt; [a]) -&gt; xxx
Copyright 2017 Austin Seipp
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
title author
Indexed Profunctor optics
Oleg Grenrus

This post is a response to the Edward's tweet:

Now try to fit all of the indexed and index-preserving variants. ;) Edward Kmett
@cjp
cjp / .el
Last active May 15, 2023 09:40
How to get org-protocol to work with spacemacs
;; I have no idea why it works. This is the product of 4 hours of trial-and-error.
(defun dotspacemacs/user-init ()
"Initialization function for user code.
It is called immediately after `dotspacemacs/init'. You are free to put almost
any user code here. The exception is org related code, which should be placed
in `dotspacemacs/user-config'."
(server-start)
(require 'org-protocol)
)