Skip to content

Instantly share code, notes, and snippets.

View Elvecent's full-sized avatar

Kirill Valiavin Elvecent

View GitHub Profile
@Elvecent
Elvecent / Bubble.dart
Last active February 2, 2023 13:25
Dart/Flutter dialog imitation with streams
import 'package:flutter/material.dart';
import 'func.dart';
class Message {
Message(this.text, this.isMe);
String text;
bool isMe;
}
@Elvecent
Elvecent / Main.hs
Last active August 10, 2022 06:11
lens-aeson madness
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Main where
import Data.Foldable
import Data.Aeson.Lens
import Data.Aeson.Encode.Pretty
import Data.Aeson.QQ
import Control.Lens
@Elvecent
Elvecent / setup.el
Created May 30, 2022 19:54
Org roam setup
(use-package org
:config
(add-hook 'text-mode-hook #'visual-line-mode)
:custom
(org-hide-leading-stars 't)
(org-startup-folded 'content ))
(use-package org-roam-ui)
(defun my-org-journal-new-entry (prefix)
@Elvecent
Elvecent / Main.hs
Created October 25, 2021 08:37
Reflex collection of counters
data AddRemove = Add Int | Remove Int deriving Show
currentId :: AddRemove -> Int
currentId = \case
Add n -> n
Remove n -> n
toMap :: AddRemove -> M.Map Int (Maybe ())
toMap = \case
Add n -> M.singleton n (Just ())
@Elvecent
Elvecent / Main.hs
Last active October 5, 2021 08:33
Async fused
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@Elvecent
Elvecent / Main.hs
Last active March 20, 2021 10:02
Selecting
import Control.Lens
import Data.Monoid
import Data.List.Extra
import Data.Foldable
select as fbs f s =
flip as s $ \a -> a <$ (
flip (fbs a) s $ \b ->
snd <$> f (a,b)
)
@Elvecent
Elvecent / Main.hs
Last active March 20, 2021 09:54
Parsing
import Data.Void
import Text.Megaparsec
import Text.Megaparsec.Char
type Parser = Parsec Void String
main :: IO ()
main = case runParser p "bruh" "\"123\", \"321\" , ," of
Left err -> print err
Right res -> print res
@Elvecent
Elvecent / default.nix
Created November 16, 2020 20:36
Haskell Nix
{ nixpkgs ? import ./nix/nixpkgs-2020-09.nix
, hls ? true
, hoogle ? true
}:
let
packageName = "template";
overlay = self: super: {
myHaskellPackages =
@Elvecent
Elvecent / Main.hs
Last active August 15, 2020 21:34
Functor list product or idk
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ConstraintKinds #-}
@Elvecent
Elvecent / haskell.md
Last active January 14, 2020 10:00
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