Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tonivade committed May 7, 2024
1 parent 4a7697e commit a95c222
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ public <T> Kind<IO<?>, T> apply(Kind<Kind<Kind<EitherK<?, ?, ?>, ConsoleAlg<?>>,
return from.fix(EitherKOf::<ConsoleAlg<?>, EmailAlg<?>, T>narrowK).foldK(
new FunctionK<>() {
@Override
public <X> Kind<IO<?>, X> apply(Kind<ConsoleAlg<?>, ? extends X> kind) {
return (Kind<IO<?>, X>) switch(kind.fix(ConsoleAlgOf::narrowK)) {
public <X> IO<X> apply(Kind<ConsoleAlg<?>, ? extends X> kind) {
return (IO<X>) switch(kind.fix(ConsoleAlgOf::narrowK)) {
case ConsoleAlg.ReadLine() -> console.readln();
case ConsoleAlg.WriteLine(var line) -> console.println(line);
};
}
},
new FunctionK<>() {
@Override
public <X> Kind<IO<?>, X> apply(Kind<EmailAlg<?>, ? extends X> kind) {
return (Kind<IO<?>, X>) switch (kind.fix(EmailAlgOf::narrowK)) {
public <X> IO<X> apply(Kind<EmailAlg<?>, ? extends X> kind) {
return (IO<X>) switch (kind.fix(EmailAlgOf::narrowK)) {
case EmailAlg.SendEmail(var to, var content)
-> console.println("email to " + to + " with content " + content);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IOProgramToState implements FunctionK<IOProgram<?>, Kind<State<?, ?>, Immu
private final Console<Kind<State<?, ?>, ImmutableList<String>>> console = StateInstances.console();

@Override
public <X> Kind<Kind<State<?, ?>, ImmutableList<String>>, X> apply(Kind<IOProgram<?>, ? extends X> from) {
public <X> State<ImmutableList<String>, X> apply(Kind<IOProgram<?>, ? extends X> from) {
return (State<ImmutableList<String>, X>) switch (from.fix(toIOProgram())) {
case IOProgram.Read() -> console.readln();
case IOProgram.Write(var value) -> console.println(value);
Expand All @@ -62,7 +62,7 @@ class IOProgramToIO implements FunctionK<IOProgram<?>, IO<?>> {
private final Console<IO<?>> console = IOInstances.console();

@Override
public <X> Kind<IO<?>, X> apply(Kind<IOProgram<?>, ? extends X> from) {
public <X> IO<X> apply(Kind<IOProgram<?>, ? extends X> from) {
return (IO<X>) switch (from.fix(toIOProgram())) {
case IOProgram.Read() -> console.readln();
case IOProgram.Write(var value) -> console.println(value);
Expand Down

0 comments on commit a95c222

Please sign in to comment.