Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
namespace Extensions.Linq
{
public static class XEnumerable
{
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source) where T : class =>
source.Where(x => x is {})!;
@Pzixel
Pzixel / Main.hs
Created December 9, 2021 10:14 — forked from krendelhoff/Main.hs
хаскельные типострадания
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Main where
As a gaming website we want to implement a tournament service with a feature called "Back a friend".
Each player holds certain amount of bonus points. Website funds its players with bonus points based on all kind of activity. Bonus points can traded to goods and represent value like real money.
One of the social products class is a social tournament. This is a competition between players in a multi-player game like poker, bingo, etc)
Entering a tournament requires a player to deposit certain amount of entry fee in bonus points. If a player has not enough point he can ask other players to back him and get a part the prize in case of a win.
In case of multiple backers, they submit equal part of the deposit and share the winning money in the same ration.
From a technical side, the following API service with 5 endpoints should be implemented
#1 Take and fund player account
GET /take?playerId=P1&points=300 takes 300 points from player P1 account
GET /fund?playerId=P2&points=300 funds (add to balance) player P2 wi
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, UndecidableInstances, LambdaCase #-}
import Control.Monad.State
import Control.Monad.Writer
import Data.Foldable
instance Monad m => Functor (CoroutineT m) where
fmap f m = CoroutineT $ do
result <- runCoroutineT m
[Obsolete("Use BaseUriClient instead")]
public abstract class BaseClient<TService> : IDisposable
{
private static readonly Dictionary<MethodBase, string> _templatesForMethods = new Dictionary<MethodBase, string>();
private const int MAX_STACKFRAME_NESTING = 10;
private readonly RestClient _client;
private readonly Uri _baseSubUri;