Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.2.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4'
}
}

Expand Down Expand Up @@ -36,8 +36,8 @@ ext {
hktBaseVersion = '0.9.3'
hktVersion = hktBaseVersion + (isSnapshot ? '-SNAPSHOT' : '')

derive4jVersion = '0.10.2'
autoService = 'com.google.auto.service:auto-service:1.0-rc2'
derive4jVersion = '0.12.3'
autoService = 'com.google.auto.service:auto-service:1.0-rc4'
}


Expand All @@ -50,14 +50,16 @@ dependencies {

compile files(Jvm.current().toolsJar)

compile 'io.kindedj:kindedj:1.0.1'

compileOnly "org.derive4j:derive4j-annotation:${derive4jVersion}"
compileOnly autoService

apt "org.derive4j:derive4j:${derive4jVersion}"
apt autoService

testCompile 'junit:junit:4.12'
testCompile 'com.google.testing.compile:compile-testing:0.8'
testCompile 'com.google.testing.compile:compile-testing:0.14'
testApt rootProject
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Wed May 04 21:04:30 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
72 changes: 42 additions & 30 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/main/java/org/derive4j/hkt/__.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.derive4j.hkt;

import io.kindedj.Hk;

/**
* Represents a higher order type (or higher kinded type or type constructor) of arity 1
* @param <f> the 'witness' of the class/interface to be lifted as type constructor: a static nested class or enum, or the class applied with wildcard type arguments.
* @param <T> the type parameter of the type constructor
*/
public interface __<f, T> {}
public interface __<f, T> extends Hk<f, T> {}
23 changes: 16 additions & 7 deletions src/main/java/org/derive4j/hkt/processor/GenCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ String prefix() {
}
private static final String CLASS_TEMPLATE = "package {0};\n" +
"\n" +
"import org.derive4j.hkt.*;\n" +
"import org.derive4j.hkt.__;\n" +
"import org.derive4j.hkt.TypeEq;\n" +
"import io.kindedj.Hk;\n" +
"{3}\n"+
"\n" +
"{1}final class {2} '{'\n" +
Expand All @@ -56,13 +58,13 @@ String prefix() {
"{4}\n" +
"}";

private static final String METHODS_TEMPLATE = " {0}static {2} {1} " +
"{4}({3} hkt) '{'\n" +
private static final String METHODS_TEMPLATE = " @SuppressWarnings(\"unchecked\")\n" +
" {0}static {2} {1} {5}({3} hkt) '{'\n" +
" return ({1}) hkt;\n" +
" }\n" +
"\n" +
" @SuppressWarnings(\"unchecked\")\n" +
" {0}static {2} TypeEq<{3}, {1}> {5}()'{'\n" +
" {0}static {2} TypeEq<{4}, {1}> {6}()'{'\n" +
" return (TypeEq) TypeEq.refl();\n" +
" }";

Expand Down Expand Up @@ -215,14 +217,21 @@ private P2<HktEffectiveVisibility, String> genCoerceMethod(TypeElement typeConst

CharSequence typeParams = MessageFormat.format(TYPE_PARAMS_TEMPLATE, showTypeParams(typeConstructor));

String hkInterfaceFQN = Visitors.asTypeElement.visit(hktInterface.asElement()).get().getQualifiedName().toString();

String kindedJInterfaceAsString = hktInterface.toString()
.replace("<" + hkInterfaceFQN, "<? extends Hk")
.replace(hkInterfaceFQN, "Hk")
.replace(packageRelativeTypeElement.getQualifiedName(), packageRelativeTypeElement.getSimpleName());

String hktInterfaceAsString = hktInterface.toString()
.replace(Visitors.asTypeElement.visit(hktInterface.asElement()).get().getQualifiedName(), hktInterface
.asElement().getSimpleName())
.replace(hkInterfaceFQN, hktInterface.asElement().getSimpleName())
.replace("io.kindedj.Hk", "Hk")
.replace(packageRelativeTypeElement.getQualifiedName(), packageRelativeTypeElement.getSimpleName());

return _P2.of(visibility,
MessageFormat.format(METHODS_TEMPLATE, visibility.prefix(), typeAsString, typeParams,
hktInterfaceAsString, coerceMethodName, typeEqMethodName));
kindedJInterfaceAsString, hktInterfaceAsString, coerceMethodName, typeEqMethodName));
}

private TypeElement packageRelativeTypeElement(TypeElement typeElement) {
Expand Down