Create an app:
play new foo
cd foo
Add dependencies to project/Build.scala
:
# Usage (from project root): ./docgen.sh <Repo Name> <Version> <Hackage Username> <Hackage Password> | |
# e.g. ./docgen.sh Bang 0.1.1.0 5outh F4kePa55word | |
#!/bin/bash | |
cabal configure && cabal build && cabal haddock --hyperlink-source \ | |
--html-location='http://hackage.haskell.org/package/$pkg/docs' \ | |
--contents-location='http://hackage.haskell.org/package/$pkg' | |
S=$? | |
if [ "${S}" -eq "0" ]; then | |
cd "dist/doc/html" | |
DDIR="${1}-${2}-docs" |
import scala.reflect.macros.Context | |
import language.experimental.macros | |
case class EnclosingApplication(tree: scala.reflect.runtime.universe.Tree) | |
object Macros { | |
def impl(c: Context): c.Expr[EnclosingApplication] = { | |
import c.universe._ | |
import treeBuild._ |
import language.experimental.macros | |
import language.implicitConversions | |
import scala.reflect.macros.Context | |
import scala.reflect.runtime.universe.Tree | |
class ReflectiveClosure[A, B](val tree: Tree, fn: Function1[A, B]) extends Function1[A, B] { | |
def apply(x: A) = fn(x) | |
} | |
object ReflectiveClosure { |
import Control.Proxy | |
import Control.Proxy.TCP | |
main :: IO () | |
main = serve (Host "0.0.0.0") "8000" $ \(socket,_) -> | |
runProxy $ socketReadS 4096 socket >-> socketWriteD socket |
{-# LANGUAGE Rank2Types | |
, RebindableSyntax | |
, ImplicitParams | |
, NoMonomorphismRestriction #-} | |
import Data.Maybe | |
import Data.Function | |
import Data.String | |
import Prelude (undefined, error, String, (++)) |
name: Python Tests | |
jobs: | |
build: | |
runs-on: ubuntu-18.04 | |
strategy: | |
max-parallel: 2 | |
matrix: | |
python-version: [3.5, 3.6, 3.7] |
#!/bin/sh | |
inPreprocessorMode () { | |
hasE=0 | |
hasU=0 | |
hasT=0 | |
for arg in "$@" | |
do | |
if [ 'x-E' = "x$arg" ]; then hasE=1; fi | |
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi |
Copy and paste the swift code below into a playground to experiment.
This is a very close emulation of Functor and Monad typeclasses in swift. However, it is very fragile (i.e. easy to crash the compiler).
For example, instance methods of fmap
will run fine, but attempting to use a globally defined fmap
that acts on Functor
types will cause a crash. Similarly for bind
. Unfortunately this means we cannot define the nice infix operator versions of these functions.
Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)
Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)
If that's the case, the indexed state monad can help!
Motivation