This file contains hidden or 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
| interface A { kind: "A", propA: string } | |
| interface B { kind: "B", propB: string } | |
| function foo(param: A | B): string { | |
| switch (param.kind) { | |
| case "A": | |
| return 'foo' | |
| case "B": | |
| return 'bar' | |
| } | |
| } |
This file contains hidden or 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
| sealed trait Or | |
| trait Left extends Or | |
| trait Right extends Or |
This file contains hidden or 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
| interface Animal { | |
| suitableFood: "grass" | |
| } |
This file contains hidden or 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
| // Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
| // Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
| var FORMAT_ONELINE = 'One-line'; | |
| var FORMAT_MULTILINE = 'Multi-line'; | |
| var FORMAT_PRETTY = 'Pretty'; | |
| var LANGUAGE_JS = 'JavaScript'; | |
| var LANGUAGE_PYTHON = 'Python'; |
This file contains hidden or 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
| import com.example.functional.env.catz._ | |
| def buildProgram[F[_] : Sync]: F[Unit] = { | |
| import cats.implicits._ | |
| for { | |
| _ <- Sync[F].delay(println("Starting")) | |
| _ <- Sync[F].delay(println("Finished")) | |
| } yield () | |
| } |
This file contains hidden or 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
| import com.example.functional.env.catz._ | |
| def buildProgram[F[_] : Sync]: F[Unit] = { | |
| import cats.implicits._ | |
| for { | |
| _ <- Sync[F].delay(println("Starting")) | |
| _ <- Sync[F].delay(println("Finished")) | |
| } yield () | |
| } |
This file contains hidden or 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
| def initUnsafe[Ctx](value: Ctx): Context[Ctx] = { | |
| Runtime({}, PlatformLive.Default).unsafeRun(Context.init(value)) | |
| } |
This file contains hidden or 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
| private[env] abstract class CatsInstance { | |
| implicit def emptyRuntime[Ctx](implicit provideEmptyEnv: ProvideEnv[Ctx]): Runtime[Ctx] = { | |
| Runtime[Ctx](provideEmptyEnv.provide, PlatformLive.Default) | |
| } | |
| } |
This file contains hidden or 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
| val context = Runtime({}, PlatformLive.Default).unsafeRun(Context.init(ExampleEnv("test"))) | |
| implicit val rts: Runtime[Context[ExampleEnv]] = Runtime(context, PlatformLive.Default) | |
| buildProgram[Env[ExampleEnv, ?]].unsafeRunSync(ExampleEnv("test")) |
This file contains hidden or 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
| object EnvFinalTaglessTest extends App { | |
| import com.example.functional.env.catz._ | |
| def buildProgram[F[_] : Sync]: F[Unit] = { | |
| import cats.implicits._ | |
| for { | |
| _ <- Sync[F].delay(println("Starting")) | |
| _ <- Sync[F].delay(println("Finished")) | |
| } yield () | |
| } |
NewerOlder