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
| //> using dep "org.apache.beam:beam-sdks-java-core:2.71.0" | |
| //> using dep "org.apache.beam:beam-runners-portability-java:2.71.0" | |
| //> using dep "org.apache.beam:beam-model-pipeline:2.71.0" | |
| //> using dep "org.slf4j:slf4j-simple:2.0.17" | |
| import org.apache.beam.model.jobmanagement.v1.JobApi; | |
| import org.apache.beam.model.pipeline.v1.RunnerApi; | |
| import org.apache.beam.runners.fnexecution.provisioning.JobInfo; | |
| import org.apache.beam.runners.jobsubmission.PortablePipelineResult; | |
| import org.apache.beam.runners.jobsubmission.PortablePipelineRunner; |
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 Unpack: | |
| import scala.quoted._ | |
| import scala.compiletime._ | |
| private def tupleType(s: String)(using q: Quotes): q.reflect.TypeRepr = | |
| import q.reflect._ | |
| val typeParams = | |
| s.map{ c => | |
| TypeRepr.of(using ConstantType(CharConstant(c)).asType) | |
| }.toList |
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 modules { | |
| // Modules examples taken from | |
| // see https://www.cs.cmu.edu/~rwh/introsml/modules/sigstruct.htm | |
| // structure IntLT = struct | |
| // type t = int | |
| // val lt = (op <) | |
| // val eq = (op =) | |
| // end |
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 shapeless.LowPriority | |
| trait Dec[T] { type V } | |
| object Dec { | |
| type ItIsYes | |
| type ItIsNo | |
| implicit def itIsNo[T](implicit l: LowPriority): No[T] = new Dec[T] { type V = ItIsNo } | |
| implicit def itIsYes[T](implicit t: T): Yes[T] = new Dec[T] { type V = ItIsYes } |
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
| {- | |
| See: http://lpaste.net/104020 | |
| and https://github.com/gonzaw/extensible-records | |
| -} | |
| module Record | |
| import Data.List | |
| %default total |
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
| module Record | |
| import Data.List | |
| %default total | |
| data IsSet : List t -> Type where | |
| IsSetNil : IsSet [] | |
| IsSetCons : Not (Elem x xs) -> IsSet xs -> IsSet (x :: xs) |
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
| final object F { | |
| type HList //<: Product with Serializable | |
| type HNil <: HList | |
| type #:[+H, +T <: HList] <: HList | |
| implicit class HListBuilder[T <: HList](h: T) { | |
| def #:[H](a: H): H #: T = F.#:(a, h) | |
| } | |
| object #: { |
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 xs = List("1", "2", "3", "foo", "bar", "4") | |
| def isAnInt(s: String): Boolean = s.matches("""-?\d+""") | |
| def toInts(is: List[String]): List[Int] = { | |
| ??? | |
| } | |
| val out = List(1, 2, 3, 4) |
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
| trait TC[F[_]] | |
| trait Foo { | |
| type I[_] | |
| implicit def tc: TC[I] | |
| } | |
| def test(g: Foo): Int = { | |
| import g._ | |
| implicitly[TC[I]](tc) // compiles |
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
| StringOrInt : Bool -> Type | |
| StringOrInt False = String | |
| StringOrInt True = Int |
NewerOlder