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
;; https://awkravchuk.itch.io/cl-fast-ecs/devlog/622054/gamedev-in-lisp-part-1-ecs-and-metalinguistic-abstraction | |
(in-package #:ecs_tutorial_sdl) | |
(define-constant +window-width+ 800) | |
(define-constant +window-height+ 600) | |
(define-constant +repl-update-interval+ 0.3d0) | |
(define-constant +font-path+ (namestring (asdf:system-relative-pathname :ecs_tutorial_sdl "Resources/inconsolata.ttf")) | |
:test #'string=) |
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 Data.Vect | |
import Data.Fin | |
%default total | |
%access public export | |
data Ty: Type where | |
TyBool: Ty | |
TyInt: Ty | |
TyFun: Ty -> Ty -> Ty |
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 GCounter | |
import Data.Fin | |
import Data.Vect | |
||| GCounter is a Conflict Free Replicated Datatype. | |
||| For a definition, see https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type | |
||| It provides update, query and merge operations. | |
||| merge is commutative, associative and idempotent. | |
data GCounter : Nat -> Type 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 Sandbox | |
import Data.Vect | |
||| zip to Vectors of the same size | |
||| using an implicit proof | |
||| instead of zippy: Vect n e -> Vect n a -> Vect n (e,a) | |
zippy : Vect n e -> Vect m a -> {auto prf: n = m}-> Vect m (e,a) | |
zippy [] [] {prf} = [] | |
zippy (x :: xs) (y :: ys) {prf = Refl} = (x, y) :: zippy xs ys |
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 Sandbox | |
import Data.Vect | |
||| zip to Vectors of the same size | |
||| using a proof that n=m | |
||| instead of zippy: Vect n e -> Vect n a -> Vect n (e,a) | |
zippy : Vect n e -> Vect m a -> (n = m)-> Vect m (e,a) | |
zippy [] [] Refl = [] | |
zippy (x :: xs) (y :: ys) Refl = (x, y) :: zippy xs ys Refl |
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 shapeless._ | |
import ops._ | |
import coproduct._ | |
object coproducttest { | |
type U = Int :+: String :+: CNil | |
type V = Double :+: List[Int] :+: CNil |
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 optionStuff | |
import scalaz._ | |
import Scalaz._ | |
object optionStuff extends App { | |
case class Test(a: Option[String], b: Option[String]) | |
case object Error | |
implicit val errorInstance = new Monoid[Error.type] { |
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
trait NaturalTransformation[-F[_], +G[_]] { | |
self => | |
def apply[A](fa: F[A]): G[A] | |
def compose[E[_]](f: E ~> F): E ~> G = new (E ~> G) { | |
def apply[A](ea: E[A]) = self(f(ea)) | |
} | |
def or[H[_]](f: H ~> G): ({type f[x] = Coproduct[F, H, x]})#f ~> G = | |
new (({type f[x] = Coproduct[F, H, x]})#f ~> G) { |
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 functional | |
trait Functor[F[_]] { | |
def fmap[A, B](fa: F[A])(f: A => B): F[B] | |
} | |
final class FunctorOps[F[_], A](val self: F[A])(implicit val F: Functor[F]) { | |
final def fmap[B](f: A => B) = F.fmap(self)(f) | |
} |
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
/** | |
* Original source: | |
* [[https://gist.github.com/oxbowlakes/970717]] | |
* | |
* Modifications: | |
* - use scala 7.0.5 | |
* - use toValidationNel | |
* - use sequenceU and traverseU instead of the lambda trick | |
* | |
* Part Zero : 10:15 Saturday Night |
NewerOlder