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
| https://floooh.github.io/2018/06/17/handles-vs-pointers.html |
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
| ;;; ob-scala.el --- org-babel functions for Scala evaluation | |
| ;; Copyright (C) 2012 Free Software Foundation, Inc. | |
| ;; Author: Andrzej Lichnerowicz | |
| ;; Keywords: literate programming, reproducible research | |
| ;; Homepage: http://orgmode.org | |
| ;; This file is part of GNU Emacs. |
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 foo | |
| import zio._ | |
| object Foo extends App { | |
| object ModuleA { | |
| type A = Has[ServiceA] | |
| trait ServiceA { |
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
| (* Coroutine implementation in OCaml, with Oleg's delimited continuation *) | |
| (* see http://okmij.org/ftp/continuations/implementations.html#caml-shift *) | |
| module D = Delimcc | |
| (* Coroutine yielded a value of type 'a, and will resume with some value of type 'b *) | |
| type ('a, 'b) suspend = | |
| | Cont of 'a * ('b, ('a,'b) suspend) D.subcont | |
| | Finish | |
| let start_coroutine 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
| type ('a, 'b) t = Done | More of 'a * ('b -> ('a, 'b) t) | |
| let gen f = | |
| (* | |
| * Note: the first value to yield gets thrown away as the generator | |
| * has not yet started. | |
| *) | |
| let start _ = | |
| let p = Delimcc.new_prompt () in | |
| Delimcc.push_prompt p begin fun () -> |
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 Test { | |
| import inc._ | |
| case class Foo(i: Int, s: String) | |
| case class Bar(f: Int, a: Foo, n: Int) | |
| val res = Bar(0, Foo(1, "hello"), 2).incBy(2) | |
| //res0: Test.Bar = Bar(2,Foo(3,hello),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
| import shapeless._ // requires.shapeless | |
| import cats._, implicits._, data.Kleisli // requires.cats | |
| import cats.sequence._ //requires kittens | |
| import cats.effect.IO //requires cats-effect | |
| // ofc, uses "-Ypartial-unification" and kind-projector | |
| case class Result() // replace with the JDBC equivalent | |
| case class DB(val r: Result) { | |
| def nextInt: IO[Int] = ??? //IO(g.nextInt) |
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 Test { | |
| case class User(name: String, age: Int) | |
| case class UserDTO(name: Option[String], age: Option[Int]) | |
| import conversions._ | |
| def a = User("John", 24).convertTo[UserDTO](Set("name")) | |
| // res0: Test.UserDTO = UserDTO(Some(John),None) | |
| case class WrongFieldNames(surname: Option[String], age: Option[Int]) |
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 Args { | |
| // it requires the cats, shapeless, and kittens libraries | |
| import cats._, implicits._ | |
| import cats.sequence._ | |
| import shapeless._, labelled._ | |
| import shapeless.syntax.singleton._ | |
| // Gitter question: | |
| // it masks fields of a record according to an explicit argument |
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
| (executable | |
| (name knapsack)) | |
NewerOlder