(draft; work in progress)
See also:
- Compilers
- Program analysis:
- Dynamic analysis - instrumentation, translation, sanitizers
#![feature(generic_associated_types)] | |
trait Functor { | |
type Unwrapped; | |
type Wrapped<A>: Functor; | |
fn map<F, B>(self, f: F) -> Self::Wrapped<B> | |
where | |
F: FnOnce(Self::Unwrapped) -> B; | |
} |
#![feature(box_syntax)] | |
use std::time::Instant; | |
enum Expr { | |
Lit(i64), | |
Var(usize), | |
Add(Box<Expr>, Box<Expr>), | |
Assign(usize, Box<Expr>), | |
Then(Box<Expr>, Box<Expr>), |
{-# language FlexibleContexts #-} | |
{-# language TypeOperators #-} | |
module DKT where | |
import Control.Monad (guard) | |
import Control.Monad.Error.Class (throwError) | |
import Control.Monad.Trans (lift) | |
import Control.Monad.Trans.State | |
import Control.Monad.Trans.Writer |
//! A doubly-linked list in 50 LOCs of stable and safe Rust. | |
// Backup-fork of https://play.rust-lang.org/?gist=c3db81ec94bf231b721ef483f58deb35 | |
use std::cell::RefCell; | |
use std::rc::{Rc, Weak}; | |
use std::fmt::Display; | |
// The node type stores the data and two pointers. | |
// | |
// It uses Option to represent nullability in safe Rust. It has zero overhead | |
// over a null pointer due to the NonZero optimization. |
(draft; work in progress)
See also:
{-# LANGUAGE ConstraintKinds, DataKinds, DeriveGeneric, DerivingVia #-} | |
{-# LANGUAGE ExplicitNamespaces, FlexibleContexts, FlexibleInstances #-} | |
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds, ScopedTypeVariables, StandaloneDeriving #-} | |
{-# LANGUAGE TypeApplications, TypeFamilies, TypeInType, TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# OPTIONS_GHC -Wall #-} | |
module Data.Aeson.Generic.DerivingVia | |
( StrFun(..), Setting(..), SumEncoding'(..), DefaultOptions, WithOptions(..) | |
, -- Utility type synonyms to save ticks (') before promoted data constructors |
module Main | |
import Data.Vect | |
-- %hide transpose | |
dot : Num a => Vect n a -> Vect n a -> a | |
dot va vb = foldr (+) 0 $ zipWith (*) va vb | |
Matrix : (rows : Nat) -> (cols : Nat) -> Type -> Type |
<template> | |
<transition | |
name="fade" | |
mode="out-in" | |
v-on:before-enter="beforeEnter" | |
v-on:enter="enter" | |
v-on:before-leave="beforeLeave" | |
v-on:leave="leave" | |
> | |
<slot></slot> |