Lens CheatSheet
-- Accessors
_Show :: (Read a, Show a) => Prism' String a
only :: Eq a => a -> Prism' a ()
type expr = | |
| MLplus | MLequal | MLfst | MLsnd | |
| MLint of int | |
| MLbool of bool | |
| MLvar of string | |
| MLcond of expr * expr * expr | |
| MLpair of expr * expr | |
| MLin of dec * expr | |
| MLabstr of pat * expr | |
| MLapp of expr * expr |
-- Accessors
_Show :: (Read a, Show a) => Prism' String a
only :: Eq a => a -> Prism' a ()
package golangglobalcachewithmutex | |
import "sync" | |
type MemCache[K comparable, T any] struct { | |
cache map[K]T | |
mutex *sync.Mutex | |
} | |
func (m MemCache[K, T]) Get(key K) (T, bool) { |
sqRootPair :: Int -> [(Int, Int)] | |
sqRootPair n = filter (\(x,y) -> x^2 + y^2 == n) | |
[(x,y) | x <- [1..n], y <- [1..n], x < y, x^2 < n, y^2 < n] | |
show' :: [(Int, Int)] -> String | |
show' ns = ((\(x,y) -> show $ x^2 + y^2) $ ns !! 0) ++ " :" ++ show ns | |
main = do | |
mapM_ (putStrLn . show') $ filter (\x -> length x /= 0) [sqRootPair n | n <- [1,3..]] |
theory CR | |
imports "~~/src/HOL/Nominal/Nominal" | |
begin | |
atom_decl var | |
nominal_datatype lambda = | |
Var var | |
| App lambda lambda (infixl "$" 120) | |
| Abs "«var»lambda" ("lam [_]._" [100,100] 100) |
definition (in Category) Iso where | |
"Iso f g ≡ (f ∘ g ≈ id (dom g)) & (g ∘ f ≈ id (dom f))" | |
definition Iso_on_objects ("_ [ _ ≅ _ ]" 40) where | |
"𝒞 [ A ≅ B ] ≡ (∃f∈Arr 𝒞. ∃g∈Arr 𝒞. f ∈ Hom[𝒞][A,B] & g ∈ Hom[𝒞][B,A] & Category.Iso 𝒞 f g)" | |
record 'c setmap = | |
setdom :: "'c set" | |
setcod :: "'c set" | |
setfunction :: "'c ⇒ 'c" |
use std::collections::HashMap; | |
fn parse_string(chars: &[char]) -> (String, &[char]) { | |
if chars[0] != '"' { | |
unreachable!() | |
} | |
let mut result = vec![]; | |
let mut index = 1; |
import React, { useState, useCallback, MouseEvent } from "react"; | |
import { css } from "@emotion/core"; | |
const RippleEffect = ({ | |
top, | |
left, | |
radius, | |
opacity, | |
transition, | |
scale, |
/** @jsx jsx */ | |
import React from "react"; | |
import { jsx, css } from "@emotion/core"; | |
export const GamingTextField: React.FC = () => { | |
return ( | |
<div | |
css={css` | |
background: linear-gradient( | |
217deg, |
type D<T> = { | |
[P in keyof T]?: T[P] extends Array<infer U> ? Array<D<U>> : T[P] | |
} | |
type W<V> = { | |
wrapper: V | |
} | |
type A = D<{ | |
hoge: number, |