Skip to content

Instantly share code, notes, and snippets.

Matt Parsons parsonsmatt

Block or report user

Report or block parsonsmatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
parsonsmatt / ugh.hs
Created Apr 13, 2018
maybe your thinking, "wow, i really want a type class with only two instances" well here you go!! don't export the class and you're *golden*. i mean, write a better error message, but come on
View ugh.hs
-- gross hack so i can lighten the syntax load
class NameOrEntityRef x where
disambiguate :: x -> Either Name EntityRef
instance NameOrEntityRef Name where
disambiguate = Left
instance NameOrEntityRef EntityRef where
disambiguate = Right
View quick-hack.hs
-- Why use `mtl` constraints?
-- well, suppose you've got some tests using `MonadState`, but then that was a
-- mistake, because of the way that Alternative's IO works:
-- you had state rollback! Oh no!
-- Fortunately, it is relatively easy to write a state instance that Just Works
-- with IO references, which preserves state across threads and exceptions.
-- And, with GeneralizedNewtypeDeriving, you get all the necessary instance
-- boilerplate for free.

fpco decided to do their own thing instead of contributing to that effort.

Your timeline is way off. The initial announcement for what would become Stackage was posted in 2012, a full three years before the post you linked was authored (and a year before Cabal got sandboxes!). The proposal blog post doesn't even mention diverging from cabal at all, and the official way to use stackage was through cabal sandboxes. The first public beta of stack was announced in June 2015, and according to the blog post, FPCo had been working on stack internally for about a year before that. If these timelines are to be believed, then stack was six months into internal produ

View checkpoint.hs
data CheckpointedException
= CheckpointedException
{ additionalContext :: BugsnagCtx
, locations :: NonEmpty Loc
, originalException :: SomeException
} deriving (Show, Typeable)
instance Exception CheckpointedException
copyCtxToEvent :: BugsnagCtx -> BugsnagEvent -> BugsnagEvent
parsonsmatt /
Created Dec 11, 2017
A basic draft of a future blog post

The question of "How do I design my application in Haskell?" comes up a lot. There's a bunch of perspectives and choices, so it makes sense that it's difficult to choose just one. Do I use plain monad transformers, mtl, just pass the parameters manually and use IO for everything, the ReaderT design pattern, free monads, freer monads, some other kind of algebraic effect system?!

The answer is: why not both/all?

Lately, I've been centering on a n application design architecture with roughly three layers:

Layer 1:

newtype AppT m a = AppT { unAppT :: ReaderT YourStuff m a } deriving ............ The ReaderT Design Pattern, essentially. This is what everything gets boiled down to, and what everything eventually gets interpreted in. This type is the backbone of your app. For some components, you carry around some info/state (consider [MonadMetrics](https://hackage

View modlist.hs
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
import GHC.TypeLits
import Data.Proxy
newtype ModList (mod :: Nat) a = ModList { unModList :: [a] }
View gist:29d0b64c2b3f4565a9fc70555273fa82
$ stack ghci --package case-insensitive
> import Data.CaseInsensitive as CS
> :set -XOverloadedStrings
> "ß" == "SS"
λ> "ß" == "ss"
λ> "ß" == "s"
View tycon.hs
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module TyCon where
import GHC.Exts (Constraint)
View waterfall.hs
module Waterfall.Base where
import Control.Monad.ST
import Data.Foldable (for_)
import Data.STRef
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as MU
rainfallBase :: [Int] -> Int
rainfallBase xs = sum (zipWith (-) mins xs)
View stack-8.2.1.yaml
compiler-check: match-exact
compiler: ghc-8.2.1
resolver: nightly-2017-07-21
sha1: bdede26c1a2cfcf4ebb08329853d285e32213b3d
content-length: 175053796
You can’t perform that action at this time.