Skip to content

Instantly share code, notes, and snippets.

package shajra.learn
import shajra.learn.typeclass.Functor
import shajra.learn.typeclass.Functor.Syntax._
trait Mu[F[_]] {
def fold[X](k: F[X] => X): X
def pipeline_update:
{
"name": .name,
"template": "c12e-ci",
"label_template": (.name + "-${COUNT}"),
"enable_pipeline_locking": false,
"materials": [
{
"type": "git",
"attributes": {
package com.work.learn
package typeclass
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
object Functor {
{-# LANGUAGE NoImplicitPrelude #-}
import qualified Prelude as P
main :: P.IO ()
main = P.putStrLn "Test suite not yet implemented"
a :: P.Maybe P.Bool
@shajra
shajra / nix-install-multiuser.log
Last active May 14, 2016 03:27
This install script (second file) used to work months ago, but now it gives me an error (first file)
The user `nixbld1' is already a member of `nixbld'.
The user `nixbld2' is already a member of `nixbld'.
The user `nixbld3' is already a member of `nixbld'.
The user `nixbld4' is already a member of `nixbld'.
The user `nixbld5' is already a member of `nixbld'.
The user `nixbld6' is already a member of `nixbld'.
The user `nixbld7' is already a member of `nixbld'.
The user `nixbld8' is already a member of `nixbld'.
The user `nixbld9' is already a member of `nixbld'.
The user `nixbld10' is already a member of `nixbld'.
@shajra
shajra / ContentNegotiate.scala
Last active January 30, 2021 20:35
Very unpolished (and likely to change) stab at content negotiation in HTTP4S
package shajra.extn.http4s.core
import org.http4s.
{ Charset, CharsetRange, ContentCoding, EntityEncoder, HasQValue, Header,
HeaderKey, Headers, LanguageTag, MediaRange, MediaType, QValue }
import org.http4s.headers.
{ Accept, `Accept-Encoding`, `Accept-Charset`, `Accept-Language`,
`Content-Encoding`, `Content-Type` }
import org.http4s.util.CaseInsensitiveString
@shajra
shajra / ReadV.scala
Last active March 27, 2016 22:28
I've found this useful for accessing nested data with accumulated error reporting.
package shajra.extn.scalaz
import scalaz.
{ \/, Arrow, Applicative, Foldable, Functor, IsomorphismApplicative,
IsomorphismFunctor, IsomorphismMonoid, IsomorphismPlus,
IsomorphismSemigroup, Kleisli, Maybe, Monoid, NonEmptyList, Plus,
ProChoice, Semigroup, Validation }
import scalaz.Isomorphism.
{ <=>, <~>, <~~>, IsoBifunctorTemplate, IsoFunctorTemplate, IsoSet }
@shajra
shajra / tagless.scala
Created March 10, 2016 05:47
Example of using a tagless encoding (rough draft)
package shajra.tagless
import argonaut.{ HCursor, DecodeResult, DecodeJson, Parse }
import argonaut.Argonaut.jString
import scalaz._
import scalaz.Isomorphism.<~>
import scalaz.syntax.monad._
@shajra
shajra / Pools.scala
Created February 28, 2016 23:30
using phantom types to keep track of thread pool types carefully
import java.util.concurrent.ExecutorService
import scalaz.Maybe
import scalaz.syntax.maybe._
final case class Pools(cpu: Maybe[Pool[Pool.Cpu]], io: Maybe[Pool[Pool.Io]])
object Pools {
def none: Pools = Pools(Maybe.empty, Maybe.empty)
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()