Skip to content

Instantly share code, notes, and snippets.

View AlexeyRaga's full-sized avatar

Alexey Raga AlexeyRaga

  • Arbor Networks
  • Sydney, Australia
View GitHub Profile
@AlexeyRaga
AlexeyRaga / 1 - MessageCodec.cs
Last active March 8, 2021 14:33
Serialisation stuff
// A Codec interface. Specific _CODECS_ (and not messages)
// should be implementing this interface.
public interface IMessageCodec<T>
{
string Encode(T value);
T Decode(string value);
}
name: Haskell
defaults:
run:
shell: bash
on: [push]
jobs:
build:
@AlexeyRaga
AlexeyRaga / tasks.json
Created August 16, 2020 10:22
VSCode Haskell Tasks
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "bash",
"args": ["-lc", "cabal new-build && echo 'Done'"],
"group": {
"kind": "build",
@AlexeyRaga
AlexeyRaga / 1CPrelude.hs
Created March 31, 2020 06:15
1с-подобный Хаскель
---------------- Базовое ----------------------
type Число = Int
type Строка = Text
type Строчное = Show
type ИО = IO
type Сравнимое = Eq
type Упорядоченное = Ord
печатать :: Строчное значение => значение -> ИО ()
печатать = print
@AlexeyRaga
AlexeyRaga / keybase.md
Created August 25, 2019 21:59
Keybase.md

Keybase proof

I hereby claim:

  • I am alexeyraga on github.
  • I am alexeyraga (https://keybase.io/alexeyraga) on keybase.
  • I have a public key ASAis1a3Gr1CpMTgz_q68t-MjHvmvAb4ufLbr67fdlRh0wo

To claim this, I am signing this object:

@AlexeyRaga
AlexeyRaga / cabal.nix
Created August 8, 2018 13:01 — forked from codebje/cabal.nix
Build a multi-project Cabal application with Nix
with builtins; rec {
cabalProjects = listToAttrs (if pathExists ./cabal.project
then projectParse
else [ { name = baseNameOf ./.; value = ./.; } ] );
projectParse = let
contents = readFile ./cabal.project;
trimmed = replaceStrings ["packages:" " "] ["" ""] contents;
packages = filter (x: isString x && x != "") (split "\n" trimmed);
package = p: substring 0 (stringLength p - 1) p;
paths = map (p: let p' = package p; in { name = p'; value = toPath (./. + "/${p'}"); } ) packages;
@AlexeyRaga
AlexeyRaga / AlmostOOP.hs
Created June 27, 2018 10:40
"Object Oriented Programming" in Haskell
class Monad m => NotificationQueue m where
readNotifications :: m [Message]
ackNotification :: Message -> m ()
class Repository m where
readRules :: S3Location -> m (Maybe [Rule])
writePolicies :: S3Location -> [Policy] -> m (Maybe ETag)
readSubmissions :: ( NotificationQueue m

Preposition

In FP we love to compose things.

When we have two functions:

f :: a -> b
g :: b -> c

then we can compose them into one function:

@AlexeyRaga
AlexeyRaga / Main.hs
Created September 9, 2017 20:35 — forked from rahulmutt/Main.hs
Fast coproducts for Haskell & Eta
#!/usr/bin/env stack
{- stack
--resolver lts-6.27
--install-ghc
runghc
--package containers
-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
@AlexeyRaga
AlexeyRaga / SimpleEchoServer.hs
Created May 30, 2017 10:52 — forked from rhwlo/SimpleEchoServer.hs
simple echo server in Haskell
import GHC.IO.Handle (Handle, hGetLine)
import GHC.IO.Handle.FD (stdout)
import Network
import Text.Printf
main :: IO ()
main = withSocketsDo $ do
listenSock <- listenOn $ PortNumber 9999
(listenHandle, clientHost, clientPort) <- accept listenSock