Skip to content

Instantly share code, notes, and snippets.

View zkbpkp's full-sized avatar

Daniil Kolesnichenko zkbpkp

  • Moscow, Russian Federation
View GitHub Profile
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
lens get set next value = fmap (set value) . next . get $ value
-- | A lens focusing on the first element in a pair
_1 :: Lens (a, x) (b, x) a b
_1 = lens fst (\(_, b) a -> (a, b))
-- | A lens focusing on the second element in a pair
_2 :: Lens (x, a) (x, b) a b
_2 = lens snd (\(a, _) b -> (a, b))
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE RankNTypes #-}
module Main where
import Data.Functor.Const
import Data.Functor.Identity (Identity (..))
import Data.Monoid
data Profile = Profile {user :: User}
@cdepillabout
cdepillabout / example.nix
Last active February 7, 2023 03:52
Example of overriding a GHC core Haskell package with Nix
# This file is an example of overriding a GHC core Haskell library (like
# bytestring, containers, text, unix, etc) when building a Haskell package.
let default-nixpkgs =
builtins.fetchTarball {
# nixpkgs haskell-updates branch as of 2019/09/15.
url = "https://github.com/NixOS/nixpkgs/archive/a51b3367ab6acc72630da0bad50ce14fa86996d0.tar.gz";
sha256 = "05d3jxxk5dxzs9b3nan16lhkrjnzf0bjd4xy66az86fsafnrr9rd";
};
in
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
/-
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
notation, basic datatypes and type classes
-/
prelude
notation `Prop` := Sort 0
import { stateShape } from '../store'
type ClientOrdersProps = {
orders: number[],
id: number,
}
const ClientOrders = ({ orders, id }: ClientOrdersProps) =>
<div>
{orders.map( order => <div>{order}</div> )}

[Know about it][Understanding][Clear understanding]

NOVICE

CONCEPTS

  • xxx Immutable Data
  • xxx Second-Order Functions
  • xxx Constructing & Destructuring
  • xxx Function Composition
  • xxx First-Class Functions & Lambdas
(set-env!
:source-paths #{"cljs"}
:dependencies '[[adzerk/boot-cljs "1.7.228-1"]
[adzerk/boot-reload "0.4.12"]
;; project dependencies
[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]
[reagent "0.6.0"
:exclusions [cljsjs/react
anonymous
anonymous / pycdump.py
Created November 10, 2015 17:19
Dump .pyc file (Python 3.5 version)
#
# read a .pyc file and pretty-print it
#
# copied from http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
# and updated to Python 3.5 (Nov 10th 2015)