These programs are safe to refactor:
object p1 {
val x = 1 + 123
val y = 1 + 123
}
public void CreateExpression() | |
{ | |
Type argType = typeof (MyClass); | |
string propertyName = "Name"; | |
ParameterExpression paramExpression = Expression.Parameter(argType, "item"); | |
//Create "item.Name" and "item.GetType()" expressions | |
var propertyAccessExpression = Expression.Property(paramExpression, propertyName); | |
var getTypeExpression = Expression.Call(paramExpression, "GetType", Type.EmptyTypes); |
{ | |
"envelope_id": "f34c6197-a7ef-45ed-acad-4d5a3147ec86", | |
"payload": { | |
"token": "Pct6Sm6JynybrFXkjEiH7hhX", | |
"team_id": "T02NDBHSWSG", | |
"api_app_id": "A03BLN935DK", | |
"event": { | |
"type": "message", | |
"subtype": "message_changed", | |
"message": { |
{ | |
"envelope_id": "012327ef-4c84-41e3-a952-09af25782c17", | |
"payload": { | |
"token": "Pct6Sm6JynybrFXkjEiH7hhX", | |
"team_id": "T02NDBHSWSG", | |
"api_app_id": "A03BLN935DK", | |
"event": { | |
"client_msg_id": "0837851c-2d34-4d4d-804c-7aed753c3421", | |
"type": "message", | |
"text": "Hello world", |
>>>>0: https://hangzhou.testnet.tezos.serokell.team/version | |
>>>>1: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/protocols | |
>>>>2: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/contracts/tz1ZSedNyGuqibEYCPbuMS3yEhhLHfZEuLtA/counter | |
>>>>3: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/contracts/tz1ZSedNyGuqibEYCPbuMS3yEhhLHfZEuLtA/manager_key | |
>>>>4: https://hangzhou.testnet.tezos.serokell.team/monitor/bootstrapped | |
>>>>5: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/context/constants | |
>>>>6: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/hash | |
>>>>7: https://hangzhou.testnet.tezos.serokell.team/chains/main/chain_id | |
>>>>8: https://hangzhou.testnet.tezos.serokell.team/chains/main/chain_id | |
>>>>9: https://hangzhou.testnet.tezos.serokell.team/chains/main/blocks/head/helpers/scripts/simulate_operation |
A type variable can be either universally ("for all x, then ...") or existentially quantified ("there exists some x, ...").
(If you're a maths persons, this corresponds to ∀x. x
and ∃x. x
, respectively)
In haskell, universally quantified type vars are represented with a forall
:
head :: forall a. [a] -> Maybe a
$ cabal run exe:coffer -- create diogo/google-work \
--field user:dcastro@serokell.com \
--field pw:123 \
--field url:www.google.com
[SUCCESS] Entry created at '/diogo/google-work'
$ cabal run exe:coffer -- create diogo/google-home \
import shapeless._ | |
import shapeless.ops.record.Keys | |
import shapeless.ops.hlist.Selector | |
import shapeless.tag._ | |
/** | |
* Gets the name of a case class's field, in a type-safe way. | |
* If the class does not have a field with the given name, the program won't compile. | |
* | |
* Kinda similar to C#'s `nameof` operator, but not bolted onto the language |
import shapeless._, record._ | |
import io.circe._ | |
import io.circe.syntax._ | |
import io.circe.generic.encoding._ | |
case class Person(name: String, age: Int) | |
object Person { | |
implicit val encodePerson: Encoder[Person] = | |
ReprObjectEncoder.deriveReprObjectEncoder.contramap { person => |
This tutorial assumes you're already familiar with Haskell's kind system and extensions like DataKinds
.
If not, please read my blog post first </shameless-plug>
.
Say you want to model a TCP connection, and it can be in either an "open" or "closed" status.
data Connection = MkConnection ...