Skip to content

Instantly share code, notes, and snippets.

Victor Nazarov sviperll

  • Moscow, Russia
Block or report user

Report or block sviperll

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
Map<String, Integer> map = // ...
int limit = 50;
PriorityQueue<Map.Entry<String, Intger>> queue = new PriorityQueue<>(limit, Comparator.comparing(Map.Entry::getValue).reversed());
for (var entry: map.entrySet()) {
if (queue.size() == limit) {
queue.remove(); // Remove MAXIMAL element
sviperll /
Created Oct 2, 2018
Try (aka Exception-monad) for Java
package com.github.sviperll;
import com.github.sviperll.exception.ExceptionfulConsumer;
import com.github.sviperll.exception.ExceptionfulFunction;
import com.github.sviperll.exception.ExceptionfulRunnable;
import com.github.sviperll.exception.ExceptionfulSupplier;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Optional;
import java.util.function.Function;
sviperll / anti-if-case.markdown
Last active Jun 20, 2016
On layered architecure and naturalness of internal data-types
View anti-if-case.markdown

On layered architecure and naturalness of internal data-types

After reading Make Everything The Same post by Sandi Metz I've started thinking about one of my own experiences with software design. During the evolution of one system I've faced a challenge of extending billing subsystem. I've actually spent couple of days thinking about the problem and this process in foresight seems very similar to one described be Sandi. At first everything seemed clear about problem, but I hated conditionals that have sprung into life. This raise of conditionals seemed both inevitable, but somehow artificially inflicted.

sviperll /
Last active Aug 29, 2015
* @author Victor Nazarov <>
public class GADT<T> extends GADTBase<GADT<Integer>, GADT<Boolean>, GADT<T>> {
public static GADT<Integer> literal(int i) {
return new GADT<Integer>(GADTBase.<GADT<Integer>, GADT<Boolean>, GADT<Integer>>_literal(i));
sviperll / gist:3734802
Created Sep 16, 2012
More thoughts on new lazy pure functional programming language to run on JVM
View gist:3734802
class List implements Monad {
(:), nil, (++), null public;
(:), nil constructor;
(:) :: forall a. a -> this a -> this a;
nil :: forall a. this a;
(++) :: forall a. List a -> List a -> List a;
(x:?xs) ++ ys = x : (xs ++ ys);
nil? ++ ys = ys;
sviperll / gist:2762734
Created May 21, 2012
My thoughts on new programming language
View gist:2762734

I have been thinking a lot about implementing functional lazy language targeting JVM with syntax like:

class Maybe a = Just a | Nothing
  implements Monad, Eq when a implements Eq, Ord when a implements Ord
  where {
    derive Ord;
    derive Eq;
    override {
You can’t perform that action at this time.