Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
module Experiment where
import Control.Lens
import Control.Lens.TH (makeClassyPrisms)
import Control.Monad.Error.Class
@techtangents
techtangents / oss ideas.txt
Last active April 4, 2018 01:02
oss ideas
Laws checking for quickcheck.
toText :: Text1 -> Text
Heyting algebra
cabal2nix as a nix expression
Morgan's debugA
Extra combinator in `loops` package.
Configurator needs interpolation in integer fields.
let
nixpkgs = import ./nixpin.nix { };
compiler = "default";
inherit (nixpkgs) pkgs;
sources = {
text1 = pkgs.fetchFromGitHub {
owner = "qfpl";
{ mkDerivation, aeson, aeson-pretty, base, blaze-html, bytestring
, data-default, either, free, lens, optparse-applicative
, QuickCheck, semigroups, stdenv, system-filepath, tasty
, tasty-hunit, tasty-quickcheck, text, text1, time, url
, xml-conduit, xml-conduit-decode
}:
mkDerivation {
pname = "brazil";
version = "0.1.0.0";
src = ./.;
{}:
let
nixpkgs = import ./nixpin.nix { };
sources = {
text1 = nixpkgs.fetchFromGitHub {
owner = "qfpl";
repo = "text1";
rev = "a6ec5284a6320f160c9fc749b7a5472e8c122da5";
@techtangents
techtangents / FreeDom.purs
Last active June 17, 2017 03:54
FreeDom.purs
module FreeDom where
import Control.Monad.Free
import Control.Monad.Free.Trans
import DOM
import DOM.HTML
import DOM.HTML.Window
import DOM.Node.Node
import DOM.Node.Types
import Data.Array
Proof of the functor laws for the Maybe functor
fmap :: (a -> b) -> Maybe a -> Maybe b
fmap f (Just x) = Just (f x)
fmap f Nothing = Nothing
Prove:
fmap id = id
Case 1: Just x
import java.util.function.Function;
public class Blah {
private Blah() {
}
static class A {
}
Higher-kinded types in Java
===========================
If we consider that types classify values, then kinds classify types.
To use Haskell notation, simple java types are of kind * - the kind of types of values.
Generic types (e.g. List) are of kind * -> * - this is essentially a type-level
function - pass a type parameter A to the List type constructor and you get a List<A>.
Higher-kinded types are (basically) of kind (* -> *) -> *.
package com.example;
public abstract class Either<A, B> {
public abstract <T> T fold(final F<A, T> af, final F<B, T> bf);
private Either(){}
public static <A, B> Either<A, B> a(final A a) {
return new Either<A, B>() {