Skip to content

Instantly share code, notes, and snippets.

View tonymorris's full-sized avatar

Tony Morris tonymorris

View GitHub Profile
@tonymorris
tonymorris / everyN.hs
Last active August 29, 2015 13:58 — forked from anonymous/everyN.hs
module Every where
import Control.Lens
import Control.Monad.Fix
-- |
--
-- >>> everyN 2 []
-- []
--
import System.Environment
import System.IO
import Control.Monad (when)
matchGlob :: String -> String -> Bool
matchGlob = undefined
main :: IO ()
main = do
args <- getArgs

Parametricity, or Theorems for Free

Say more by saying less. Learn how parametric types, when used in conjunction with an adequately strong type system, help the programmer comprehend code by invalidating candidate programs. Parametricity helps the programmer by enabling deduction of theories about what a program cannot do, sometimes to the point of leaving no ambiguity.

Response to https://peerj.com/preprints/826v1/
1.
The method is dubious with respect to the conclusion.
The researchers do not analyse the code using any formal
or even established reliable methods. Instead, the metric that is used is "look
to see if some *detected* bug, which was fixed *post-release*.
  • mount indicators
  • install air filter
  • install rear rack
  • install braided fuel line
  • install headlight protector
  • mount spotlights
  • install windscreen
  • change oil filters
  • install foam air filter
  • adjust rear shock
// see https://github.com/gseitz/Lensed
case class CoState[A, B](put: A => B, pos: A)
object CoState {
type Store[A, B] = CoState[A, B]
}
// fused get/set
case class Lens[A, B](lens: A => CoState[B, A]) {
name: package
version: 0.0.1
license: BSD3
license-File: LICENCE
category: Development
cabal-version: >= 1.10
build-type: Custom
flag small_base
description: Choose the new, split-up base package.

There seems to be a lot of confusion around Effects and IO. I wanted to collect a set of questions and answers, and explanations of common misconceptions.

  1. What is an Effect?

Effects come in many different shapes. In terms of monadic effects, there are different shapes again. For example, List (non-determinism), State, IO, Cont.

  1. What is a Side Effect?

An effect that is occurs to the side of the effect you are otherwise running within. In most standard environments, this is an IO effect that occurs outside of the otherwise effectful environment.

import Control.Applicative
import Control.Concurrent (forkIO, newEmptyMVar, putMVar, takeMVar)
import Control.Monad
import Control.Monad.Trans.Class
import Control.Monad.IO.Class
import System.Command
newtype Cmd m a = Cmd { runCmd :: m (Either (Int, String) a) }
cmd :: MonadIO m => FilePath -> [String] -> String -> Cmd m String
@tonymorris
tonymorris / Monad.cc
Created January 2, 2014 02:59 — forked from mxswd/Monad.cc
#include <tr1/type_traits>
#include <iostream>
#include <vector>
#include <algorithm>
// (* -> *) -> Constraint
template<template <typename> class T>
class Functor {
public:
template <typename A, typename B>