Skip to content

Instantly share code, notes, and snippets.

@mgsloan
mgsloan / roam-navigator-theme.css
Created Jun 29, 2020
CSS for overriding Roam Navigator visual hint styles (https://github.com/mgsloan/roam-navigator). Can be used in extensions like Roam Toolkit (Custom CSS feature) or Stylish
View roam-navigator-theme.css
.roam_navigator_hint {
color: purple !important;
font-size: 20px !important;
}
.roam_navigator_hint_typed {
color: orange !important;
}
.roam-sidebar-container .roam_navigator_hint, #right-sidebar .roam_navigator_hint {
@mgsloan
mgsloan / roam-backup.sh
Created Jun 22, 2020
Roam backup shell script
View roam-backup.sh
#!/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
View error-monoid-maybe-int-ddump
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 =>
View desugar-local-typeable.hs
-- 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 Sep 11, 2019
Iffy desugaring idea for local types
View desugar-local-types.md

Context: https://github.com/ghc-proposals/ghc-proposals/pull/273#issuecomment-530203676

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

View riodocs.diff
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
View 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 Nov 26, 2017
MIT license applies to all my public gists
View MIT-LICENSE.md

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 Nov 26, 2017
pre-commit hook to ensure no ignored files are in the commit (even if you used "git add --force")
View pre-commit
#!/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
View gist:f728ae5bb502518c242972b35c136f63
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)
}