Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
@danidiaz
danidiaz / Konjugation.txt
Created November 5, 2017 09:40
Konjugation
https://www.verbformen.de/konjugation/?w=sein
https://www.verbformen.de/konjugation/?w=haben
https://www.verbformen.de/konjugation/?w=m%C3%BCssen
https://www.verbformen.de/konjugation/?w=k%C3%B6nnen
sein
Präsens Präeteritum
ich bin war
du bist warst
er/es/sie ist war
wir sind waren
@danidiaz
danidiaz / Dockerfile
Last active September 20, 2018 13:28
docker + docker-compose for local Haskell development
from ubuntu:latest
run apt-get update && \
apt-get install -y emacs agda-mode agda-stdlib && \
apt-get install -y coq coqide && \
apt-get install -y openssh-server && \
apt-get install -y iproute2 wget curl && \
apt-get install -y bzip2 tmux git vim libgmp-dev python3 gcc libtinfo-dev zlib1g-dev xz-utils make && \
git config --global core.editor vim && \
git config --global alias.co checkout && \
@danidiaz
danidiaz / Joining CSV Tables in Haskell.md
Created October 23, 2017 13:25 — forked from nkpart/Joining CSV Tables in Haskell.md
Joining CSV Tables in Haskell

Joining CSV Tables in Haskell

This article describes a technique for joining (in an SQL-style) lists of haskell data structures.

Maybe not the fastest, maybe not the smartest, but it works.

Why I like it

(This answer pilfers wholesale from [this other answer][1] its example of histomorphism on lists.)
A simple —and not very compelling— example of chronomorphism would be a "safe tail" function for run-length-encoded lists:
tailRunLen :: [(Int,a)] -> Maybe [a]
tailRunLen = chrono alg coalg
where
alg v = case v of
Nil -> Nothing -- empty list
Cons _ (b :< x) -> case x of

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
package com.alexr.dynaenum;
import java.io.*;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
@danidiaz
danidiaz / pom.xml
Last active September 27, 2017 20:35
Maven Cargo plugin example configuration. Includes container dependencies and a datasource definition https://codehaus-cargo.github.io/cargo/Maven2+Plugin+Reference+Guide.html#Maven2PluginReferenceGuide-dependency using the <properties> tag seems to be an alternative way of defining datasources https://codehaus-cargo.github.io/cargo/DataSource+a…
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.4</version>
<configuration>
<container>
<containerId>tomee7x</containerId>
<dependencies>
<dependency>
<!-- It seems the dependency must also be present,
@danidiaz
danidiaz / cargo.txt
Last active July 2, 2019 06:36
maven cargo plugin
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.4</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<!--
<type>embedded</type>
@danidiaz
danidiaz / YetAnotherPipesTextExample.hs
Last active August 27, 2017 21:26
Yet another pipes text example
module Main where
import Pipes
import qualified Pipes.Prelude as P
import qualified Pipes.Group as PG
import qualified Pipes.ByteString as PB
import qualified Pipes.Text as PT
import Pipes.Text.Encoding (utf8)
import qualified Control.Foldl as L
import qualified Control.Foldl.Text as LT
@danidiaz
danidiaz / IsRecord.hs
Last active August 12, 2017 09:52
IsRecord constraint using generics-sop type-level metadata. Related to https://gist.github.com/danidiaz/3f396f92a6dda1cff87639ec4f1194df
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Soapy (IsRecord) where
import GHC.TypeLits (Symbol)
import Generics.SOP
import qualified Generics.SOP.Type.Metadata as T
type IsRecord (r :: *) (mn :: Symbol) (dn :: Symbol) (cn :: Symbol) (fs :: [T.FieldInfo]) (xs :: [*]) =
(IsProductType r xs, DatatypeInfoOf r ~ T.ADT mn dn '[T.Record cn fs], T.DemoteFieldInfos fs xs)