Skip to content

Commit 2ee2950

Browse files
committed
Removed IOW
1 parent 202f88c commit 2ee2950

File tree

4 files changed

+30
-47
lines changed

4 files changed

+30
-47
lines changed

core/src/main/java/fj/data/IO.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* Created by MarkPerry on 19/06/2014.
55
*/
66

7+
import fj.F;
8+
import fj.Unit;
9+
710
import java.io.IOException;
811

912
/**
@@ -13,8 +16,33 @@
1316
*
1417
* @param <A> the type of the result produced by the IO
1518
*/
19+
@FunctionalInterface
1620
public interface IO<A> {
1721

1822
A run() throws IOException;
1923

24+
default SafeIO<Validation<IOException, A>> safe() {
25+
return IOFunctions.toSafeValidation(this);
26+
}
27+
28+
default <B> IO<B> map(F<A, B> f) {
29+
return IOFunctions.map(this, f);
30+
}
31+
32+
default <B> IO<B> bind(F<A, IO<B>> f) {
33+
return IOFunctions.bind(this, f);
34+
}
35+
36+
default <B> IO<B> append(IO<B> iob) {
37+
return IOFunctions.append(this, iob);
38+
}
39+
40+
public static IO<LazyString> getContents() {
41+
return () -> IOFunctions.getContents().run();
42+
}
43+
44+
public static IO<Unit> interact(F<LazyString, LazyString> f) {
45+
return () -> IOFunctions.interact(f).run();
46+
}
47+
2048
}

core/src/main/java/fj/data/IOW.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

core/src/main/java/fj/data/SafeIO.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* Created by MarkPerry on 3/07/2014.
55
*/
6+
@FunctionalInterface
67
public interface SafeIO<A> extends IO<A> {
78

89
@Override

demo/src/main/java/fj/demo/IOWalkthrough.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import fj.Unit;
55
import fj.data.IO;
66
import fj.data.IOFunctions;
7-
import fj.data.IOW;
87

98
import java.io.BufferedReader;
109
import java.io.IOException;
@@ -72,7 +71,7 @@ public static void main(String[] args) {
7271
// for composing IO values instead, the entire program can be written like so:
7372

7473
F<String, String> f = String::toUpperCase;
75-
IOW.lift(stdoutPrintln("What's your name again?"))
74+
stdoutPrintln("What's your name again?")
7675
.append(stdoutPrint("Name: "))
7776
.append(stdinReadLine())
7877
.bind(f.andThen(IOFunctions::stdoutPrintln))

0 commit comments

Comments
 (0)