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 com.example | |
// Define the State monad | |
case class State[S, A](run: S => (S, A)) { | |
// Execute the state computation and return the final state | |
def exec(s: S): S = run(s)._1 | |
// Evaluate the state computation and return the result | |
def eval(s: S): A = run(s)._2 | |
} |
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 com.example.macros | |
import scala.deriving.Mirror | |
import scala.compiletime.{erasedValue, constValue, summonInline} | |
// Domain Model | |
case class Address(street: String, postalcode: String, city: String, country: String) | |
case class Student(name: String, age: Int, address: Address) | |
case class Classroom(name: String, students: List[Student]) | |
case class School(name: String, classrooms: List[Classroom]) |
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 com.example | |
type TupleMy2 = [X] =>> (X, X) | |
trait Foldable[C[_]]: | |
def foldr[A, B](xs: C[A])(init: B)(fx: (A, B) => B): B | |
object FoldableInstances: | |
given listFoldable: Foldable[List] with |
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 sparktutorial | |
object ChainingPartialFunction { | |
type Parser = PartialFunction[Seq[String], ((String,String), Seq[String])] | |
val inputPath: Parser = { | |
case ("-i" | "--in" | "--inpath") +: path +: tail => (("input-path", path), tail) |