Skip to content
Merged
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
16 changes: 3 additions & 13 deletions core/src/main/java/fj/Bottom.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ public static <A> P1<A> error_(final String s) {
* @return A function that throws an error using the given message, ignoring its argument.
*/
public static <A, B> F<A, B> errorF(final String s) {
return new F<A, B>() {
public B f(final A a) {
return a -> {
throw new Error(s);
}
};
}

Expand Down Expand Up @@ -87,11 +85,7 @@ public static <A> Error decons(final java.lang.Class<A> c) {
* @return A function that returns the <code>toString</code> for a throwable.
*/
public static <T extends Throwable> F<T, String> eToString() {
return new F<T, String>() {
public String f(final Throwable t) {
return t.toString();
}
};
return t -> t.toString();
}

/**
Expand All @@ -100,10 +94,6 @@ public String f(final Throwable t) {
* @return A function that returns the <code>getMessage</code> for a throwable.
*/
public static <T extends Throwable> F<T, String> eMessage() {
return new F<T, String>() {
public String f(final Throwable t) {
return t.getMessage();
}
};
return t -> t.getMessage();
}
}
41 changes: 17 additions & 24 deletions core/src/main/java/fj/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,24 @@ private Class(final java.lang.Class<T> c) {
*/
public List<Class<? super T>> inheritance() {
return unfold(
new F<java.lang.Class<? super T>, Option<P2<java.lang.Class<? super T>, java.lang.Class<? super T>>>>() {
public Option<P2<java.lang.Class<? super T>, java.lang.Class<? super T>>> f(
final java.lang.Class<? super T> c) {
if (c == null)
return none();
else {
final P2<java.lang.Class<? super T>, java.lang.Class<? super T>> p =
new P2<java.lang.Class<? super T>, java.lang.Class<? super T>>() {
public java.lang.Class<? super T> _1() {
return c;
}
(java.lang.Class<? super T> c2) -> {
if (c == null)
return none();
else {
final P2<java.lang.Class<? super T>, java.lang.Class<? super T>> p =
new P2<java.lang.Class<? super T>, java.lang.Class<? super T>>() {
public java.lang.Class<? super T> _1() {
return c;
}

@SuppressWarnings({"unchecked"})
public java.lang.Class<? super T> _2() {
return c.getSuperclass();
}
};
return some(p);
}
}
}, c).map(new F<java.lang.Class<? super T>, Class<? super T>>() {
public Class<? super T> f(final java.lang.Class<? super T> c) {
return clas(c);
}
});
@SuppressWarnings({"unchecked"})
public java.lang.Class<? super T> _2() {
return c.getSuperclass();
}
};
return some(p);
}
}, c).map(c1 -> clas(c1));
}

/**
Expand Down
24 changes: 4 additions & 20 deletions core/src/main/java/fj/Digit.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,20 @@ public static Option<Digit> fromChar(final char c) {
/**
* First-class conversion from digit to a long.
*/
public static final F<Digit, Long> toLong = new F<Digit, Long>() {
public Long f(final Digit d) {
return d.toLong();
}
};
public static final F<Digit, Long> toLong = d -> d.toLong();

/**
* First-class conversion from a long to a digit.
*/
public static final F<Long, Digit> fromLong = new F<Long, Digit>() {
public Digit f(final Long i) {
return fromLong(i);
}
};
public static final F<Long, Digit> fromLong = i -> fromLong(i);

/**
* First-class conversion from a digit to a character.
*/
public static final F<Digit, Character> toChar = new F<Digit, Character>() {
public Character f(final Digit d) {
return d.toChar();
}
};
public static final F<Digit, Character> toChar = d -> d.toChar();

/**
* First-class conversion from a character to a digit.
*/
public static final F<Character, Option<Digit>> fromChar = new F<Character, Option<Digit>>() {
public Option<Digit> f(final Character c) {
return fromChar(c);
}
};
public static final F<Character, Option<Digit>> fromChar = c -> fromChar(c);
}
13 changes: 3 additions & 10 deletions core/src/main/java/fj/Effect.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,12 @@ public static <A, B, C, D, E> F5<A, B, C, D, E, Unit> f(Effect5<A, B, C, D, E> z
* @return An effect after a contra-variant map.
*/
public final <A, B> Effect1<B> comap(Effect1<A> e1, final F<B, A> f) {
return new Effect1<B>() {
public void f(final B b) {
e1.f(f.f(b));
}
};
return b -> e1.f(f.f(b));
}

public static <A> Effect1<A> lazy(final F<A, Unit> f) {
return new Effect1<A>() {
public void f(final A a) {
f.f(a);
}
};
return a -> f.f(a);

}

// public static <A> void f(Effect1<A> )
Expand Down
Loading