|
MapFromStringToInteger.java
|
package com.acme.maps;
import church.lang.ByteStream;
import church.lang.Hash.$HashCode;
import church.lang.operators.Relational.$$equal;
import church.lang.operators.Streams.$$encode;
import church.primitives.Integers;
import church.primitives.Objects;
import church.util.HashMap;
import church.util.HashMap.$Map;
import church.util.HashMap.$OutEntry;
import static church.lang.operators.Streams.output;
import static church.util.Entry.entry;
import static church.util.HashMap.get;
@SuppressWarnings("unchecked")
public class MapFromStringToInteger {
private static final $$equal<String> $S0 = Objects::$equal;
private static final $HashCode<String> $S1 = Objects::hashCode;
private static final $Map<String, Integer> $S2 = HashMap.map($S0, $S1);
private static final $$encode<ByteStream, String> $S3 = Objects::$encode;
private static final $$encode<ByteStream, Integer> $S4 = Integers::$encode;
private static final $OutEntry<ByteStream, String, Integer> $S5 = HashMap.outEntry($S4, $S3, $S3);
private static final $$encode<ByteStream, HashMap<String, Integer>> $S6 = HashMap.$encode($S5);
public static void main(String[] args) {
HashMap<String, Integer> a = $S2.map(entry("foo", 2), entry("bar", 4));
$S3.$encode($S6.$encode($S3.$encode(output, "a = "), a), "\n");
int e1 = get(a, "foo");
$S3.$encode($S4.$encode($S3.$encode(output, "a.get(\"foo\") = "), e1), "\n");
int e2 = get(a, "foo");
$S3.$encode($S4.$encode($S3.$encode(output, "a[\"foo\"] = "), e2), "\n");
assert get(a, "foo") == 2;
}
}