This file contains 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 OverloadedStrings #-} | |
module Assistant (module Assistant) where | |
import Data.Kind (Type) | |
import Data.Text (Text) | |
import Telegram.Bot.API (Token (..), Update, defaultTelegramClientEnv) | |
import Telegram.Bot.Simple (BotApp (..), startBot_, (<#)) | |
import Telegram.Bot.Simple qualified as TBS |
This file contains 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
module Lib (module Lib) where | |
import Control.Applicative (Applicative (liftA2)) | |
import Data.Foldable | |
import Data.Functor ((<&>)) | |
-- OCaml be like: | |
-- + | |
incrementInt :: Int -> Int | |
incrementInt n = n + 1 |
This file contains 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 Batteries.Data.RBMap.Basic | |
open Batteries | |
-- `Ordering` is used instead of mainstream languages' approach with (-1, 0, 1) and consits of: | |
-- lt - less than (-1) | |
-- eq - equals (0) | |
-- gt - greater than (1) | |
-- This one sparks joy. |
This file contains 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 Batteries.Data.RBMap | |
inductive BinOp where | |
| add | sub | mul | div | |
deriving Repr, Ord | |
-- Abstrct Syntax Tree | |
inductive Expr where | |
| bool (value : Bool) | |
| num (value : Int) |
This file contains 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 Batteries.Data.RBMap | |
inductive BinOp where | |
| add | sub | mul | div | |
deriving Repr, Ord | |
-- Abstrct Syntax Tree | |
inductive Expr where | |
| num (value : Int) | |
| var (name : String) |
This file contains 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 ImplicitParams #-} | |
module DI (module DI) where | |
import Control.Monad.Reader (MonadReader (ask), ReaderT (runReaderT)) | |
data Database = MkDatabase | |
data User = MkUser deriving (Show) | |
data Request = MkRequest Int | |
data Response = MkResponse String |
This file contains 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
/// Usecases. | |
type Ordering = | |
| -1 // Less than | |
| 0 // Equal | |
| 1; // Greater than | |
const LT: Ordering = -1; | |
const EQ: Ordering = 0; | |
const GT: Ordering = 1; |
This file contains 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
package main | |
import ( | |
"io/fs" | |
"os" | |
) | |
// Manual | |
func bracket[R any](acquire func() (R, error), release func(R) error, use func(R) error) error { | |
r, err := acquire() |
This file contains 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
exp(E) --> int(E). | |
exp(E) --> binop(E). | |
int(I) --> [I], { integer(I) }. | |
binop(add(A, B)) --> "+", exp(A), exp(B). | |
binop(sub(A, B)) --> "-", exp(A), exp(B). | |
binop(mul(A, B)) --> "*", exp(A), exp(B). | |
binop(div(A, B)) --> "/", exp(A), exp(B). |
This file contains 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
@module("ethers") external decodeBase58Unsafe: string => bigint = "decodeBase58" | |
@get external code: Js.Exn.t => string = "code" | |
@get external argument: Js.Exn.t => string = "argument" | |
@get external value: Js.Exn.t => string = "value" | |
@get external shortMessage: Js.Exn.t => string = "shortMessage" | |
type decodeBase58Error = | |
| UnknownError | |
| InputError({ |
NewerOlder