Skip to content

Instantly share code, notes, and snippets.

View vyorkin's full-sized avatar
❤️‍🔥

Vasiliy Yorkin vyorkin

❤️‍🔥
View GitHub Profile
@vyorkin
vyorkin / ParentView.purs
Created December 23, 2018 15:45 — forked from prathje/ParentView.purs
Raw Halogen HTML Component
module ParentView where
import Prelude
import Halogen as H
import Halogen.HTML as HH
import Halogen.HTML.Events as HE
import Halogen.HTML.Properties as HP
import Data.Maybe (Maybe(..))
import Control.Monad.Aff (Aff)
# ETHEREUM_SCHEME=https ETHEREUM_HOST="ropsten.infura.io" ETHEREUM_PORT=443 iex -S mix
Application.put_env(EVM, :debugger, true)
EVM.Debugger.Breakpoint.init()
EVM.Debugger.Breakpoint.set_breakpoint(%EVM.Debugger.Breakpoint{conditions: [address: <<188, 31, 252, 22, 32, 218, 20, 104, 98, 74, 89, 108, 184, 65, 211, 94, 107, 47, 31, 182>>]})
load_hex = fn("0x" <> hex_string) ->
padded_hex_string = if rem(byte_size(hex_string), 2) == 1, do: "0" <> hex_string, else: hex_string
{:ok, hex} = Base.decode16(padded_hex_string, case: :lower)
module Test.RowListMaps where
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.Maybe (fromJust)
import Data.StrMap as SM
import Data.Tuple (Tuple(..))
import Data.Variant (Variant, inj, SProxy(..))
import Global.Unsafe (unsafeStringify)
import Partial.Unsafe (unsafePartial)
@vyorkin
vyorkin / MapRecord.purs
Created April 22, 2018 15:02 — forked from i-am-tom/MapRecord.purs
MapRecord for PureScript, with and without comments!
module MapRecordWithComments where
-- | Type-level Tomfoolery. A million thankyous to @kcsongor and his
-- | unparallelled patience with me while I try to figure this stuff
-- | out.
import Prelude (($), (+), (<>), discard, show)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
@vyorkin
vyorkin / ZipRecord.purs
Created April 22, 2018 15:02 — forked from i-am-tom/ZipRecord.purs
ZipRecord for PureScript. More notes from RowToList studies.
module Main (main, zip, zipRecord, class ZipRowList) where
-- | After Tuesday's experiments, let's move onto a slightly more
-- | interesting example. Last time, I confess, I cheated a bit to
-- | avoid getting too deep into RowToList stuff. Today, I'm not
-- | going to cheat, and get riiiight into it. When we're thirty lines
-- | in, don't say you weren't warned!
import Prelude (($), discard, Unit)
import Control.Monad.Eff (Eff)
@vyorkin
vyorkin / extract-fieldnames.purs
Created April 22, 2018 15:02 — forked from justinwoo/extract-fieldnames.purs
extract field names from rows using rowtolist
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Type.Proxy (Proxy(..))
import Type.Row (class ListToRow, class RowToList, Cons, Nil, kind RowList)
@vyorkin
vyorkin / DiffRecords.purs
Created April 22, 2018 15:02 — forked from anilanar/DiffRecords.purs
lodash.without in purescript using RowToList
{-
This is just adventuring with RowToList.
Naive approach, not stack safe, probably too slow.
-}
module DiffRecords
where
import Data.Record (get, insert)
import Data.Symbol (class IsSymbol, SProxy(..))
class SemigroupJoinRecord rl (row ∷ # Type) where
appendRecordsImpl :: RLProxy rl → Record row -> Record row -> Record row
instance semigroupJoinRecordCons ∷ (Semigroup ty, RowCons name ty row' row, SemigroupJoinRecord tail row, IsSymbol name) ⇒ SemigroupJoinRecord (Cons name ty tail) row where
appendRecordsImpl _ r1 r2 =
let
_name = (SProxy ∷ SProxy name)
v1 = get _name r1
@vyorkin
vyorkin / Main.purs
Created April 22, 2018 15:01 — forked from coot/Main.purs
PureScript: pick subrecords from a record.
module Main where
import Prelude
import Data.Foldable (fold, elem)
import TryPureScript
import Type.Row (class ListToRow, class RowToList, Cons, Nil, kind RowList)
import Type.Proxy (Proxy(..))
import Type.Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Array (cons)
import Data.Monoid (mempty)
@vyorkin
vyorkin / ZipDisjointRecord.purs
Created April 22, 2018 15:01 — forked from i-am-tom/ZipDisjointRecord.purs
Zipping records with mismatched keys.
module Main (main, zip, zipRecord, class ZipRowList) where
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.Record (get, insert)
import Data.Symbol (class IsSymbol, SProxy(..))
import Data.These (These(..))
import Global.Unsafe (unsafeStringify)
import Prelude (Unit, discard)
import Type.Row