In your command-line run the following commands:
brew doctor
brew update
Can we do it with `ClassTag` ? | |
Adriaan: | |
You can't with a class tag, as it represents the erased type as known to the JVM. You could use a TypeTag | |
to reify the full type, but that depends on full scala reflection, which has its own downsides | |
(not thread safe, basically pulls in the compiler,...) | |
scala> import scala.reflect.runtime.universe.TypeTag | |
import scala.reflect.runtime.universe.TypeTag |
trait Coercible[A, B] { | |
def coerce(a: A): B | |
} | |
def coerce[A, B](a: A)(implicit coerceAB: Coercible[A, B]): B = { | |
coerceAB.coerce(a) | |
} | |
trait Newtype[+T] { | |
val value: T |
In your command-line run the following commands:
brew doctor
brew update
# start postgresql | |
pg_ctl -D /usr/local/var/postgres start | |
# stop postgresql | |
pg_ctl -D /usr/local/var/postgres stop |
import Control.Monad | |
------------------------------------------------------------------------------- | |
-- State Monad Implementation | |
------------------------------------------------------------------------------- | |
newtype State s a = State { runState :: s -> (a,s) } | |
instance Monad (State s) where | |
return a = State $ \s -> (a, s) |
""" | |
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go | |
on a url, use the urlsafe version. Then decode the byte string so that it can be else where. | |
""" | |
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode() | |
# And the decode is just as simple... | |
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode()) | |
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary |
package org.example; | |
import scala.Function1; | |
import scala.collection.generic.CanBuildFrom; | |
import scala.collection.immutable.List; | |
import scala.collection.immutable.List$; | |
import scala.collection.immutable.Vector; | |
import scala.collection.immutable.Vector$; | |
import scala.collection.mutable.Builder; |
type Valid[M[_], A] = EitherT[M, AccountServiceException, A] | |
type AccountOperation[M[_], A] = Kleisli[Valid[M, ?], AccountRepository[M], A] |
I hereby claim:
To claim this, I am signing this object: