Skip to content

Instantly share code, notes, and snippets.

@kgtkr
Created April 29, 2020 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgtkr/29bc4a405c4ec5b32a77c903bfbdf554 to your computer and use it in GitHub Desktop.
Save kgtkr/29bc4a405c4ec5b32a77c903bfbdf554 to your computer and use it in GitHub Desktop.
cycleもどきをScalaでいい感じにしたい
class Stream[A] {}
class VNode[M] {}
// tagless finalでとりあえずMonad制約つける感じでEffect制約つけると合成とかできて便利だよみたいなあれ
trait Effect[A] {
def zero: A;
def merge(x: A, y: A): A;
// mergeの中で自動的にisolateする感じでもいい気はする?
// そしたらこれMonoidじゃん。可換Monoidでもよさそ
// でもisolateせずにマージするパターンもあるしうーん
def isolate(a: A): A;
}
trait HttpEffect[A] {
def response: Stream[String]
def get(url: Stream[String]): A;
}
trait StateEffect[S, A] {
def state: Stream[S];
def reducer(f: Stream[S => S]): A
}
trait DomEffect[M, A] {
def msgs: Stream[M];
def vnode(vnode: Stream[VNode[M]])
}
object Child1Component {
def apply[A: Effect](): A = ???
}
object Child2Component {
def apply[A: Effect](): A = ???
}
object RootComponent {
def apply[A: Effect](): A = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment