Created
April 29, 2020 13:41
-
-
Save kgtkr/29bc4a405c4ec5b32a77c903bfbdf554 to your computer and use it in GitHub Desktop.
cycleもどきをScalaでいい感じにしたい
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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