Skip to content

Instantly share code, notes, and snippets.

View jyrimatti's full-sized avatar

Jyri-Matti Lähteenmäki jyrimatti

View GitHub Profile
#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages(p: with p; [type-level-sets])"
#! nix-shell -I nixpkgs=channel:nixos-18.03
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
@jyrimatti
jyrimatti / oip.hs
Last active October 6, 2016 19:14
Optics in Programming (https://lahteenmaki.net/dev_*16/) - code. Executable file. Or paste to Haskell-for-Mac.
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p "haskellPackages.ghcWithPackages(p: with p; [profunctors mtl lens])"
ghci <<---EOF
:set +m
:set -XRank2Types
:set -XScopedTypeVariables
{-# LANGUAGE Rank2Types, ScopedTypeVariables #-}
import Data.Tuple (swap)
import Data.Monoid (First(..), getFirst, (<>))
Verifying that +jyrimatti is my blockchain ID. https://onename.com/jyrimatti

Keybase proof

I hereby claim:

  • I am jyrimatti on github.
  • I am jyrimatti (https://keybase.io/jyrimatti) on keybase.
  • I have a public key whose fingerprint is 38E6 FC6A C104 7CEC 71CE 71E7 1959 B8A4 F22F EC94

To claim this, I am signing this object:

{-# LANGUAGE TupleSections #-}
module Main where
-- hide the-dot to use it from Control.Category
import Prelude hiding ((.))
import Control.Category
import Control.Monad ((<=<))
import Control.Comonad.Env
import Control.Arrow
import Data.Profunctor
@jyrimatti
jyrimatti / Main.hs
Created September 22, 2015 20:47
Aeson example
-- build with cabal file:
-- name: aeson-ex
-- version: 0.1
-- build-type: Simple
--
-- executable aeson_ex
-- hs-source-dirs: src
-- main-is: Main.hs
-- build-depends: base >= 4,
@jyrimatti
jyrimatti / gist:89a6313692d47b4a3225
Created August 29, 2015 20:22
My public key fingerprint
38E6 FC6A C104 7CEC 71CE 71E7 1959 B8A4 F22F EC94
@jyrimatti
jyrimatti / gist:3868667
Created October 10, 2012 21:47
"Alternative way" for https://class.coursera.org/progfun-2012-001/lecture/index Week 3 Rational definition
// These should already exist in a standard library or similar
trait Showable[T] {
val show: T => String
}
trait StandardShowables {
implicit object StringIsShowable extends Showable[String] {
val show = (a: String) => a
}
implicit object BooleanIsShowable extends Showable[Boolean] {
val show = (a: Boolean) => a.toString