Skip to content

Instantly share code, notes, and snippets.

@okkero
okkero / Test.java
Last active March 22, 2018 16:38
Java 10 type inference bug: inference fails on list of objects of two different classes derived from the same base class, implementing the same interface. Error:java: java.lang.AssertionError: Unexpected intersection type: com.okkero.Test.Super&com.okkero.Test.Foo
public class Test {
interface Foo {}
static abstract class Super {}
static class Sub1 extends Super implements Foo {}
static class Sub2 extends Super implements Foo {}
public static void main(String[] args) {
@okkero
okkero / hkt.cpp
Created February 11, 2018 21:50
C++ HKT
#include <iostream>
#include <functional>
#include <optional>
template<template<typename> typename F>
struct Functor
{
template<typename A, typename B>
static F<B> map(const F<A> &, const std::function<B (const A &)> &);
};
#![feature(slice_patterns)]
type PhonebookError = String;
#[derive(Debug)]
struct PhonebookEntry
{
name: String,
phone_numbers: Vec<u32>
}
module Main where
import Control.Monad
import Data.Char
import Data.Either
import Data.List.Split
type PhonebookError = String
data PhonebookEntry = PhonebookEntry
@okkero
okkero / Main.idr
Created December 17, 2017 14:57
Idris-JVM Spigot plugin
module Main
import IdrisJvm.FFI
import IdrisJvm.IO
import Java.Lang
%default total
record Java a ret where
@okkero
okkero / Main.hs
Created December 17, 2017 14:40
Eta Spigot plugin
{-# LANGUAGE TypeFamilies, DataKinds #-}
module Main where
import Java
import System.IO
data Command = Command @org.bukkit.command.Command
deriving Class
import Data.List
onOdds :: ([a] -> [a]) -> [a] -> [a]
onOdds f xs =
let
(odds, evens) = partition (odd . fst) $ zip [0..] xs
in
concat $
zipWith
(\a b -> [a, b])