This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; }; | |
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>; | |
template<class Variant, class... Ts> | |
auto match(Variant v, Ts... matchers) { | |
return visit(overloaded{matchers...}, v); | |
} | |
struct Human {string name; int age;}; | |
struct Animal {string kind; int age;}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import operator | |
from typing import Callable, NamedTuple, Optional, TypeVar, Generic | |
A = TypeVar('A') | |
class Lazy(Generic[A]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#define LAZY(expression) Lazy<Cons>{[=]{ return expression.get(); }} | |
#define LAZY_REF(expression) Lazy<Cons>{[&]{ return expression.get(); }} | |
template<typename T> | |
class Lazy { | |
private: | |
mutable shared_ptr<T> value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <complex> | |
using namespace std; | |
#include <numbers> | |
using namespace std::numbers; | |
struct Expr { | |
virtual string source() const = 0; | |
virtual shared_ptr<Expr> derive() const = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
data Expr | |
= Lit Integer | |
| Var | |
| Add Expr Expr | |
| Mul Expr Expr | |
| Pow Expr Expr | |
| Sin Expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Control.Monad.State | |
data Action | |
= For Expr (Expr -> Action) | |
| Print Expr | |
data Expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
-- | This module contains usage example of suggested `MonadParsecDbg` type class, | |
-- minimized, but, I hope, demonstrative | |
-- | |
-- If someone have better solution, I would like to see it | |
module Main where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MonadComprehensions #-} | |
{-# LANGUAGE OverloadedLists #-} | |
{-# LANGUAGE RebindableSyntax #-} | |
import Data.Set (Set, singleton) | |
import GHC.Exts | |
import Prelude | |
xs :: Set Int | |
xs = [3, 15] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveTraversable #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Mystudies where | |
import Data.Foldable (toList) | |
import Data.Functor.Foldable (fold) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.IO.Class (liftIO) | |
import Data.Text (Text) | |
import qualified Data.Text as Text | |
import Telegram.Bot.API (Chat (..), ChatType (..), Message (..), | |
ParseMode (Markdown), Update (..), | |
defaultTelegramClientEnv) | |
import Telegram.Bot.Simple (BotApp (..), BotM, Eff, getEnvToken, | |
reply, replyMessageParseMode, startBot_, | |
toReplyMessage, withEffect) | |
import Telegram.Bot.Simple.Debug (traceBotDefault) |
NewerOlder