Skip to content

Instantly share code, notes, and snippets.

View adamczykm's full-sized avatar
💭
Hi.

Michał Adamczyk adamczykm

💭
Hi.
  • Europe / Poland
View GitHub Profile
@adamczykm
adamczykm / NewtypeHelpers.purs
Last active August 18, 2022 14:46
Better helpers for Purescript's Newtype class
module Data.Newtype.Helpers
( (#<)
, flipViaR
, over
, over''
, under
, under''
, viaR
, viaR''
, viaW

Keybase proof

I hereby claim:

  • I am adamczykm on github.
  • I am adamczykm (https://keybase.io/adamczykm) on keybase.
  • I have a public key ASAAX_2oOFLt0vXUBrLW7zORAuAI1ai6X_BdgKMjaohBMQo

To claim this, I am signing this object:

module ThrottleDebounce
( ThrottlingContext
, newThrottlingContext
, debounce
, throttle
) where
import Control.Applicative (pure)
import Control.Bind (bind, discard, (>>=))
module ThrottleDebounce
( ThrottlingContext
, newThrottlingContext
, debounce
) where
import Control.Applicative (pure)
import Control.Bind (bind, discard, (>>=))
import Data.DateTime (DateTime)
module Utils where
import Data.Array (snoc)
import Data.FormURLEncoded (FormURLEncoded(..))
import Data.Function (($))
import Data.Maybe (Maybe(..))
import Data.Monoid (mempty)
import Data.Symbol (class IsSymbol, SProxy, reflectSymbol)
import Data.Tuple (Tuple(..))
import Heterogeneous.Folding (class FoldingWithIndex, class HFoldlWithIndex, hfoldlWithIndex)
module Utils where
import Data.Array (snoc)
import Data.FormURLEncoded (FormURLEncoded(..))
import Data.Function (($))
import Data.Maybe (Maybe(..))
import Data.Symbol (class IsSymbol, SProxy, reflectSymbol)
import Data.Tuple (Tuple(..))
import Heterogeneous.Folding (class FoldingWithIndex, class HFoldlWithIndex, hfoldlWithIndex)
@adamczykm
adamczykm / AlternativeFoldableContainer.purs
Last active November 19, 2018 18:32
Alternative + Foldable = Container
include :: forall a f. Alternative f => a -> f a -> f a
include a f = pure a <|> f
select :: forall a f. Functor f => Foldable f => f a -> Maybe a
select f = unwrap $ fold (First <<< Just <$> f)
@adamczykm
adamczykm / Default.purs
Created November 8, 2018 03:44
A class for types that supports default values.
module Default where
import Control.Category (identity, (<<<))
import Data.Maybe (Maybe(..))
import Data.Symbol (class IsSymbol, SProxy(..))
import Data.Tuple (Tuple(..))
import Prim.Row as Row
import Prim.RowList (class RowToList, Cons, Nil, kind RowList)
import Record.Builder (Builder)
import Record.Builder as Builder
apiGet
:: forall e m p
. MonadJsonHttp e m => MonadApiAccess m => WriteForeign { | p } => Lacks "login" p => Lacks "passwd" p
=> ApiRoute → { | p } → ExceptV e m Json
apiGet route params = do
{login, password, apiUrl} <- lift getApiAccess
let inter = insert (SProxy :: SProxy "passwd") password params
authP = insert (SProxy :: SProxy "login") login inter
get (apiUrl <> route) authP
function createElement(type, config, children) {
var propName = void 0;
// Reserved names are extracted
var props = {};
var key = null;
var ref = null;
var self = null;
var source = null;