Skip to content

Instantly share code, notes, and snippets.

@mgsloan
mgsloan / blah.hs
Created April 7, 2012 19:35
Lined up variant
zipProducers :: Producer a m r -> Producer b m r -> Producer (a, b) m r
zipProducers (Pure r) _ = return r
zipProducers _ (Pure r) = return r
zipProducers (M m1) (M m2) = lift m1 >>= \p1 -> lift m2 >>= \p2 -> zipProducers p1 p2
zipProducers (M m1) p2 = lift m1 >>= \p1 -> zipProducers p1 p2
zipProducers p1 (M m2) = lift m2 >>= \p2 -> zipProducers p1 p2
zipProducers (Await f1) (Await f2) = zipProducers (f1 ()) (f2 ())
zipProducers (Await f1) p2 = zipProducers (f1 ()) p2
@mgsloan
mgsloan / gist:4186049
Created December 2, 2012 00:11
transitive descendents
import Control.Applicative
import Control.Lens
import Data.Data
import Data.Data.Lens
descendents :: (Data a, Data b) => (b -> Bool) -> Fold a b
descendents p f = biplate go
where
go x
| p x = f x
@mgsloan
mgsloan / Bar.hs
Last active December 10, 2015 01:48 — forked from anonymous/Bar.hs
module Bar where
bar = answer * 20
#!/bin/bash
ext=$1
rsync -aL --delete ~/fpco/ide/ ~/build/fpco-$ext/
cd ~/build/fpco-$ext
perl -i -pe "s~/fpco/ide/~/build/fpco-$ext/~g;" \
.hsenvs/*/.hsenv/bin/activate \
@mgsloan
mgsloan / gist:6050213
Last active December 20, 2015 01:39 — forked from wcauchois/gist:6050119
GeocodeResponse latLng <- callJsonEndpoint $ GeocodeEndpoint targetAddress False
let venuesTrendingEndpoint = VenuesTrendingEndpoint latLng Nothing Nothing `authorizeWith` creds
VenuesTrendingResponse venues <- callJsonEndpoint venuesTrendingEndpoint
let printVenue v = putStrLn $ "- " ++ name v
mapM_ printVenue venues
@mgsloan
mgsloan / Vacuum.hs
Last active December 20, 2015 04:09
import GHC.Vacuum
import GHC.Vacuum.GraphViz
import Data.GraphViz
lazyVacuumToPng :: FilePath -> a -> IO FilePath
lazyVacuumToPng fp x = graphToDotFile fp Png $ nameGraph (vacuumLazy x)
main :: IO ()
main = do
lazyVacuumToPng "beforeForce" xs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
module Slogger where
-- | Load all of the hints at compile time.
hlintFixities :: [HSE.Fixity]
hlintClassifies :: [Classify]
hlintBuiltins :: [String]
hlintRules :: [HintRule]
(hlintFixities, hlintClassifies, hlintBuiltins, hlintRules) =
$(do let dataDir = "../learning-site/config/hlint/"
(builtin, matches) <- TH.qRunIO $ findSettings dataDir (dataDir </> "HLint.hs") Nothing
let (classify, rules) = concat2 $ map readSettings matches
-- All of these helpers are copied from HLint
@mgsloan
mgsloan / haskell-highlighting.md
Created November 20, 2014 22:25
Github haskell highlighting issues

Hello!

Github is awesome! However, a minor issue report:

Very recently the code highlighting changed, to the detriment of haskell highlighting. Others have noticed too, an example comment: https://github.com/chrisdone/hindent/issues/36#issuecomment-63157052

The old highlighting doesn't need to come back, however, here are a couple immediately apparent issues:

  1. The last type in a function type signature seems to get a different color, for no good reason
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.Trans
import GHCJS.DOM
import GHCJS.DOM.Node
import Style
import Util