Skip to content

Instantly share code, notes, and snippets.


  • Russia
Block or report user

Report or block Elvecent

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Elvecent / Server.hs
Created Dec 6, 2019
WebSocket chat that fails
View Server.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Server (talk, newServer, Server) where
import Control.Concurrent.Async
import Control.Concurrent.STM
import Control.Exception
import Control.Monad
import Data.Foldable (traverse_)
import Data.Functor (void)
View Main.hs
module Main where
-- from "monoidal-containers" package
import qualified Data.IntMap.Monoidal.Strict as M
-- The thing with this IntMap is that whenever
-- its elements form a semigroup, the IntMaps
-- containing those elements themselves form
-- a monoid that works "pointwise"
-- Just type synonyms
Elvecent / App.tsx
Last active Oct 28, 2019
Nice React counter
View App.tsx
import { createContext, useContext, useReducer } from "react";
import * as React from "react";
import { render } from "react-dom";
// <LibraryCode>
const StateContext: React.Context<[any, React.Dispatch<any>]> = createContext(
function StateProvider<S, A>({
Elvecent / Pure.hs
Created Sep 11, 2019
Deep Pure Fun
View Pure.hs
{-# LANGUAGE TypeApplications, DataKinds, KindSignatures, TypeFamilies, MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}
module Main where
import Data.Functor.Compose
import Data.Functor.Identity
import Data.Coerce
data Nat = Zero | Succ Nat
Elvecent / Concurrent.hs
Last active Sep 1, 2019
Running jobs asynchronously but yielding results in order
View Concurrent.hs
module Utils.Concurrent (mkPipeline, launchNukes) where
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async (Async, async, cancel, wait)
import Control.Concurrent.STM (TBQueue, atomically, newTBQueueIO,
readTBQueue, writeTBQueue)
import Control.Monad (forever, void)
import Control.Monad.IO.Class (MonadIO, liftIO)
import GHC.Natural (Natural)
Elvecent / Main.hs
Last active Sep 14, 2019
Free Monad & Cofree Comonad
View Main.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Main where
Elvecent / Main.hs
Created Aug 15, 2019
Cool coroutines with free monad transformers
View Main.hs
-- packages "free" and "transformers" assumed
{-# LANGUAGE DeriveFunctor #-}
module Main where
import Control.Monad.Trans.Free
import Control.Monad.Trans.Class
data CoroutineF a = Yield a
Elvecent / Parser.hs
Last active May 19, 2019
Monadic parsers
View Parser.hs
{-# Language DeriveFunctor #-}
module Parser where
newtype Parser a = Parser { parse :: String -> [(a, String)] }
deriving Functor
parserBind :: Parser a -> (a -> Parser b) -> Parser b
parserBind (Parser p) mf = Parser $ \s ->
p s >>= (\(x,s) -> parse (mf x) s)
Elvecent / Bubble.dart
Last active Mar 15, 2019
Dart/Flutter dialog imitation with streams
View Bubble.dart
import 'package:flutter/material.dart';
import 'func.dart';
class Message {
Message(this.text, this.isMe);
String text;
bool isMe;
Elvecent /
Last active Jan 14, 2020
Minimal Haskell Emacs

Minimal Haskell Emacs configuration, from scratch

This little instruction shows how to set up Emacs with some packages to start writing Haskell in a more or less convenient way (including, but not limited to: smart auto completion, type info, autoformatting).

Get emacs

First step: get Emacs for your platform. This should be simple.

Find your init file

That's usually ~/.emacs on unix-like systems. ~ stands for "home folder" and on Windows it's usually AppData\Roaming. Check this out.

Set up MELPA

You can’t perform that action at this time.