Skip to content

Instantly share code, notes, and snippets.

David Barri japgolly

Block or report user

Report or block japgolly

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
japgolly / Coyo.scala
Created Mar 12, 2014
Coyoneda natural transformations
View Coyo.scala
object ForScalaz {
type CoyonedaF[F[_]] = ({type A[α] = Coyoneda[F, α]})
def FG_to_CFG[F[_], G[_] : Functor, A](t: F ~> G): (CoyonedaF[F]#A ~> G) = {
type CF[A] = Coyoneda[F, A]
type CG[A] = Coyoneda[G, A]
val m: (CF ~> CG) = FG_to_CFCG(t)
val n: (CG ~> G) = CF_to_F
val o: (CF ~> G) = n compose m
View JunctionExperiment.scala
import scalaz.\/
object JunctionExperiment {
val debug = !true
View gist:816902779c457f25c87f
case class Username(value: String)
implicit val usernameCodec = implicitly[CodecJson[String]].xmap(Username.apply)(_.value)
// ------------------------------------------------------------------------------------------------
// Would like to eventually like to do something like this:
// (Basically a replacement the {@@, T with U} hack which has caused me too many problems)
trait TaggedType { type U; def value: U }
trait TaggedTypeCtor[T <: TaggedType] { def apply(u: T#U): T }
japgolly / implicits.scala
Last active Aug 29, 2015
Scala implicit search path
View implicits.scala
package lib {
trait O[A]
object O {
import F.I
implicit val Il = null.asInstanceOf[I[Long]]
implicit val Ol = null.asInstanceOf[O[Long]]
trait T {
japgolly /
Last active Aug 29, 2015
scalajs-react 0.7.0 migration
find . -name '*.scala' -exec perl -pi -e '
japgolly / blah.scala
Created Dec 16, 2014
Quick script to decipher long Scala type errors
View blah.scala
import scala.language._
import scala.annotation.tailrec
object Blah {
val errmsg = """
[error] found : blah.webapp.client.lib.ui.Editor[(, (String, String,,,scalaz.effect.IO,,,scalaz.effect.IO[Unit],(japgolly.scalajs.react.vdom.ReactVDom.Tag, japgolly.scalajs.react.vdom.ReactVDom.Tag, japgolly.scalajs.react.vdom.prefix_<^.Tag)]
[error] (which expands to) blah.webapp.client.lib.ui.Editor[((Stream[], Option[]), (String, String,,,scalaz.effect.IO,,,scalaz.effect.IO[Unit],(japgolly.scalajs.react.vdom.ReactV
japgolly / gist:78507c5953d8f848f63c
Created Feb 28, 2015
Basic bootstrap NavBar model
View gist:78507c5953d8f848f63c
// In Link & MenuItem, when onClick is None it means it should be disabled.
// This enforces the invariant that disabled items cannot be clicked.
// If you want something clickable but you want it to do nothing then pass it
// a callback that does nothing: Some(IO(()))
sealed trait NavItem
case class Link(label: String, onClick: Option[IO[Unit]], active: Boolean) extends NavItem
case class DropdownMenu(items: NonEmptyList[MenuItem]) extends NavItem
View ConsoleIO.scala
package shipreq.webapp.client.lib
import org.scalajs.dom.console
import scala.annotation.elidable
import scala.scalajs.js
import scalaz.effect.IO
import js.{UndefOr, undefined}
trait ConsoleIO {
def info (msg: js.Any, extra: js.Any*) : IO[Unit]
japgolly / CssPager.scala
Created Mar 23, 2015
Chandu - CssPager
View CssPager.scala
import japgolly.scalajs.react._, vdom.prefix_<^._, ScalazReact._
import japgolly.scalacss.Defaults._
import japgolly.scalacss.ScalaCssReact._
import shapeless.syntax.singleton._
object CssPager {
type CLICKEVENT = Int => Unit
object Style extends StyleSheet.Inline {
japgolly / DependencyLib.scala
Last active Sep 24, 2015
SBT JVM/JS DependencyLib
View DependencyLib.scala
import sbt._
import scala.languageFeature._
import org.scalajs.sbtplugin.ScalaJSPlugin
import ScalaJSPlugin.autoImport._
object DependencyLib {
sealed trait HasDialect
sealed trait HasJvm extends HasDialect
sealed trait HasJs extends HasDialect
You can’t perform that action at this time.