This file contains 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 scala "3.2" | |
//> using lib "dev.zio::zio-json:0.3.0" | |
import zio.json.* | |
import zio.json.ast.Json | |
type T1 = (String, Int) | |
type T2 = (Int, String) | |
given JsonDecoder[T1 | T2] = |
This file contains 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 tactic.basic | |
import category_theory.category | |
open category_theory | |
universes u v | |
variables {C : Type u} [category.{v} C] {X Y Z : C} | |
structure are_isomorph (X Y: C) := |
This file contains 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 dottyVersion = "0.20.0-RC1" | |
lazy val root = project | |
.in(file(".")) | |
.settings( | |
name := "discipline-example", | |
version := "0.1.0", | |
libraryDependencies ++= Seq( | |
"com.novocode" % "junit-interface" % "0.11" % "test", | |
("org.typelevel" % "cats-core_2.13" % "2.0.0").withDottyCompat(scalaVersion.value), |
This file contains 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 creds { | |
val consumer_key = "" | |
val consumer_secret = "" | |
val access_token = "" | |
val access_secret = "" | |
} |
This file contains 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
{-# LANGUAGE InstanceSigs #-} | |
module State where | |
import Control.Monad | |
data Estado s a = Estado { corre :: s -> (a, s) } | |
instance Functor (Estado s) where |
This file contains 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 Chap2.PictureLanguage where | |
-- data Painter | |
-- 2.2.4 Example: A Picture Language | |
beside :: a -> a -> a | |
beside a b = undefined | |
below :: a -> a -> a | |
below bottom top = undefined |
This file contains 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 Chap2 | |
import scala.language.higherKinds | |
trait AbstractTypes { | |
type Rational[A] | |
def makeRat[A](x: A, y: A): Rational[A] |
This file contains 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 Environment[A, X](x: X) = { | |
val a: A = x | |
// this is safe iff X <: A | |
// in other words, if we discard information | |
// (otherwise we might try to use `a` in an operation it doesn't support) | |
// in other words: it is only safe to forget information | |
// another form: | |
def f(a: A) = { |
This file contains 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
-- required: stack install random | |
import System.Random | |
-------- Fermat test ----------------- | |
expmod base e m | |
| e == 0 = 1 | |
| even e = mod (expmod base (e `div` 2) m ^ 2) m | |
| otherwise = mod (base * expmod base (e - 1) m) m |
This file contains 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
// Initial object algebra interface for expressions: integers and addition | |
interface ExpAlg<E> { | |
lit(x: number): E | |
add(e1: E, e2: E): E | |
} | |
// The evaluation interface | |
interface Eval { | |
eval(): number | |
} |
NewerOlder