Skip to content

Instantly share code, notes, and snippets.

@mgsloan
mgsloan / roam-backup.sh
Created June 22, 2020 04:42
Roam backup shell script
#!/bin/sh -e
# Script I wrote before I realized
# https://github.com/MatthieuBizien/roam-to-git exists
if [ "$#" -eq 1 ]; then
LAST_ROAM_EXPORT=$1
elif [ "$#" -eq 0 ]; then
echo "Attempting to use XDG info to find roam export."
# Load XDG dir configuration into variables
ErrorMonoidMaybeInt.hs:12:3-48: Splicing declarations
explainInstanceError [t| Monoid (Maybe Int) |]
======>
main_a6aM
= putStrLn
(displayInst
(resolveMonoid (Data.Proxy.Proxy :: Data.Proxy.Proxy (Maybe Int))))
class Semigroup_ a_a4Ra => Monoid_ (a_a4Ra :: GHC.Types.Type) where
resolveMonoid :: Data.Proxy.Proxy a_a4Ra -> Inst
instance OVERLAPPABLE #-} base-4.12.0.0:Data.Typeable.Internal.Typeable a_a4Ra =>
-- Context: https://github.com/ghc-proposals/ghc-proposals/pull/273#issuecomment-530215302
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Typeable
@mgsloan
mgsloan / desugar-local-types.md
Created September 11, 2019 04:11
Iffy desugaring idea for local types

Context: ghc-proposals/ghc-proposals#273 (comment)

I have not reviewed this proposal thoroughly, however I would really like this feature and have considered proposing it in the past. To make this more clearly defined and understandable for users, I'd like to propose a simple rule for what is allowed:

Local types could desugar to top level declarations

My intuition says that if this holds true then the feature becomes much easier to implement than if it does not. As far as I can tell this rule is mostly already followed in the proposal. Specifically:

All instances remain (conceptually) global, but they may involve local types and values

diff --git a/src/RIO.hs b/src/RIO.hs
index e4e2c66..e071714 100644
--- a/src/RIO.hs
+++ b/src/RIO.hs
@@ -1,3 +1,4 @@
+-- | This mo
module RIO
( module RIO.Prelude.Display
, module RIO.Prelude.Extra
diff --git a/src/RIO/Prelude/Reexports.hs b/src/RIO/Prelude/Reexports.hs
@mgsloan
mgsloan / keybase.md
Created January 2, 2018 05:34
keybase.md

Keybase proof

I hereby claim:

  • I am mgsloan on github.
  • I am mgsloan (https://keybase.io/mgsloan) on keybase.
  • I have a public key ASD0wSGDjAfr3397iicKObFGTTGmQyUVookmyd7W7GdH-go

To claim this, I am signing this object:

@mgsloan
mgsloan / MIT-LICENSE.md
Created November 26, 2017 08:22
MIT license applies to all my public gists

All public gists which do not specify a different license, listed at https://gist.github.com/mgsloan, are covered by the MIT License, http://www.opensource.org/licenses/mit-license.php

Copyright 2017 Michael Sloan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT H

@mgsloan
mgsloan / pre-commit
Last active November 26, 2017 10:48
pre-commit hook to ensure no ignored files are in the commit (even if you used "git add --force")
#!/bin/sh
# Copyright 2017 Michael Sloan
# This file is MIT licensed.
changed="$(git diff --name-only --cached)"
changed_and_ignored="$(echo "$changed" | git check-ignore --stdin --no-index | tr -d '[:space:]')"
if test -z "$changed_and_ignored" ;
then
fn main() {
let mut x = 1;
wat(|i| { x += i; return x; });
println!("{}", x);
}
fn wat<F>(f: F) -> u32 where F: FnMut(u32) -> u32 {
foo(f)
}
@mgsloan
mgsloan / a_summary
Last active February 5, 2016 14:28
Using new-stack to build old-stack, using it to build itself, and then using old-stack to build new-stack. new-stack is stack-1.0.3, the current release, and old-stack is stack-0.1.0.0, the first stable release 7 months ago.
mgsloan@computer:~/fpco/stack$ git checkout v0.1.0.0
...
mgsloan@computer:~/fpco/stack$ stack build
...
Installing executable(s) in
/home/mgsloan/fpco/stack/.stack-work/install/x86_64-linux/lts-2.9/7.8.4/bin
Registering stack-0.1.0.0...
Completed 123 action(s).