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 scala.scalanative.unsafe.* | |
| import scala.scalanative.unsigned.* | |
| // Raw bindings | |
| @link("sodium") | |
| @extern | |
| object libsodium { | |
| def sodium_init(): CInt = extern |
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
| package net.andimiller.examples.htmx | |
| package chat | |
| import cats.implicits._ | |
| import cats.effect._ | |
| import org.http4s.{FormDataDecoder, HttpRoutes} | |
| import org.http4s.dsl.Http4sDsl | |
| import HTML._ | |
| import org.http4s.FormDataDecoder.{field, formEntityDecoder} |
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
| -- Represents a chainable functional stream | |
| -- mutable versions of methods are available under .mutate | |
| function Stream(tbl) | |
| stream = { values = tbl, mutate = {} } | |
| function stream.mutate.map(f) | |
| transform(stream.values, f) | |
| return stream | |
| end | |
| function stream.map(f) | |
| stream.values = map(stream.values, f) |
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 "CoreLibs/object" | |
| import "CoreLibs/graphics" | |
| import "CoreLibs/sprites" | |
| import "CoreLibs/timer" | |
| local gfx <const> = playdate.graphics | |
| -- playdate.display.setScale(2) | |
| tiles = gfx.imagetable.new('tiles/farm') |
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 cats.parse.Parser | |
| import cats.implicits.* | |
| import cats.* | |
| import higherkindness.droste.* | |
| object Calculator extends App: | |
| // normal expression data structure | |
| enum Expr: | |
| case Add(a: Expr, b: Expr) | |
| case Mul(a: Expr, b: Expr) |
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
| /* | |
| name := "circe-droste-parser" | |
| version := "0.1" | |
| scalaVersion := "2.12.8" | |
| libraryDependencies += "io.circe" %% "circe-rs" % "0.12.3" | |
| libraryDependencies += "io.circe" %% "circe-literal" % "0.12.3" | |
| libraryDependencies += "io.circe" %% "circe-parser" % "0.12.3" |
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 java.util.function.Function; | |
| import java.util.Optional; | |
| class Result<L, R> { | |
| enum State { | |
| Left, | |
| Right | |
| } | |
| private final State state; |
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
| case class Sized[T](bytes: Long, value: T) | |
| object Sized { | |
| implicit def sizedEntityDecoder[F[_] : FlatMap, T](implicit dec: EntityDecoder[F, T], F: Sync[F]): EntityDecoder[F, Sized[T]] = | |
| new EntityDecoder[F, Sized[T]] { | |
| override def decode(msg: Message[F], strict: Boolean): DecodeResult[F, Sized[T]] = { | |
| EitherT( | |
| for { | |
| counter <- F.delay { | |
| new LongAdder() |
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 TypeSafeBuilder { | |
| sealed trait BuilderStatus | |
| object Satisfied extends BuilderStatus | |
| object NotSatisfied extends BuilderStatus | |
| case class Cat(name: String, age: Int) | |
| object CatBuilder { | |
| def apply() = new CatBuilder[NotSatisfied.type, NotSatisfied.type](None, None) |
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
| /** | |
| A quick example of practical GADT use in Dotty | |
| val dottyVersion = "0.7.0-RC1" | |
| val scala212Version = "2.12.4" | |
| lazy val root = (project in file(".")). | |
| settings( | |
| name := "dotty-cross", | |
| version := "0.1.0", |
NewerOlder