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
| // 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 |
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 Example { | |
| // Data types | |
| sealed trait Base { | |
| sealed trait Token | |
| } | |
| sealed trait PlainText extends Base { | |
| case class PlainText(text: String) extends Token |
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 japgolly.scalajs.react._, vdom.prefix_<^._, ScalazReact._ | |
| import org.scalajs.dom.raw.HTMLSelectElement | |
| import scala.scalajs.js | |
| import scalaz.Equal | |
| import scalaz.effect.IO | |
| object SelectOne { | |
| case class Choice[A](value : A, | |
| label : String, |
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 scala.language._ | |
| import scala.annotation.tailrec | |
| object Blah { | |
| val errmsg = """ | |
| [error] found : blah.webapp.client.lib.ui.Editor[(blah.webapp.base.data.Validators.blar.scala.S, (String, String, blah.webapp.base.data.ImplicationRequired)),blah.webapp.client.app.ui.CfgBlars.fields.FieldValue,scalaz.effect.IO,blah.webapp.client.app.ui.CfgBlars.storesAndState.S,blah.webapp.client.app.ui.CfgBlars.fields.Field,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[blah.webapp.base.data.CustomBlar], Option[blah.webapp.base.data.CustomBlar.Id]), (String, String, blah.webapp.base.data.ImplicationRequired)),blah.webapp.client.app.ui.CfgBlars.fields.FieldValue,scalaz.effect.IO,blah.webapp.client.app.ui.CfgBlars.storesAndState.State,blah.webapp.client.app.ui.CfgBlars.fields.Field,scalaz.effect.IO[Unit],(japgolly.scalajs.react.vdom.ReactV |
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
| #!/bin/bash | |
| find . -name '*.scala' -exec perl -pi -e ' | |
| s/(?!<[a-zA-Z0-9_"])onblur(?![a-zA-Z0-9_"])/onBlur/g; | |
| s/(?!<[a-zA-Z0-9_"])onchange(?![a-zA-Z0-9_"])/onChange/g; | |
| s/(?!<[a-zA-Z0-9_"])onclick(?![a-zA-Z0-9_"])/onClick/g; | |
| s/(?!<[a-zA-Z0-9_"])ondblclick(?![a-zA-Z0-9_"])/onDblClick/g; | |
| s/(?!<[a-zA-Z0-9_"])onfocus(?![a-zA-Z0-9_"])/onFocus/g; | |
| s/(?!<[a-zA-Z0-9_"])onkeydown(?![a-zA-Z0-9_"])/onKeyDown/g; | |
| s/(?!<[a-zA-Z0-9_"])onkeyup(?![a-zA-Z0-9_"])/onKeyUp/g; |
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 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 { |
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
| // http://japgolly.blogspot.com.au/2014/09/an-example-of-functional-programming.html | |
| sealed trait Validity | |
| case object Valid extends Validity | |
| case class Invalid(e1: String, en: List[String]) extends Validity | |
| case class Validator[A](f: A => Validity) { | |
| @inline final def apply(a: A) = f(a) | |
| def +(v: Validator[A]) = Validator[A](a => |
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 org.scalajs.dom | |
| import org.scalajs.dom.console | |
| import scala.scalajs.js | |
| import scalaz.{Equal, State, StateT} | |
| import scalaz.std.option.optionEqual | |
| import scalaz.std.tuple.tuple2Equal | |
| import scalaz.syntax.bind._ | |
| import scalaz.effect.IO | |
| import japgolly.scalajs.react._ | |
| import japgolly.scalajs.react.vdom.ReactVDom._ |
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
| 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 } |
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 scalaz.stream.merge | |
| import scalaz.\/ | |
| import scalaz.stream.merge.Junction._ | |
| import scalaz.stream.Process._ | |
| object JunctionExperiment { | |
| val debug = !true |