Skip to content

Instantly share code, notes, and snippets.

View graninas's full-sized avatar
😊
My Twitter: graninas

Alexander Granin graninas

😊
My Twitter: graninas
View GitHub Profile
@graninas
graninas / granin_technical_writer.md
Created January 14, 2025 17:56
Alexander Granin - Technical Writer
@graninas
graninas / granin_rust_cpp.md
Last active March 11, 2025 04:12
Aleksandr Granin - Rust & C++ developer
@graninas
graninas / granin_fp.md
Last active March 11, 2025 04:13
Aleksandr Granin - Functional Developer & Software Architect
@graninas
graninas / granin_blockchain.md
Last active March 11, 2025 04:13
Aleksandr Granin - Blockchain Developer & Software Architect
@graninas
graninas / granin_educator.md
Last active March 11, 2025 04:13
Aleksandr Granin - Senior Educator

Aleksandr Granin - Senior Educator

Book Author, Experienced Software Architect, Functional Programming Expert, Educator and International Speaker


Contact Information

  • Location: Dubai, UAE
  • Phone: +971586924747
@graninas
graninas / ExistentialCollection.hs
Last active July 22, 2024 10:18
Example of a technique for Kana
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FunctionalDependencies #-}
module Main where
(* Free monads in OCaml
Code for my talk:
https://www.youtube.com/live/KdMuSH9pGsw?si=wybc5UCBua-uIzBU
*)
(* Free monads are implemented with the help of these resourses: *)
(*http://rgrinberg.com/posts/free-monads-in-the-wild-ocaml/*)
@graninas
graninas / StateLangSpec.hs
Created September 14, 2023 15:24
Church Free monad based State
module StateLangSpec where
import Test.Hspec
import Data.IORef
import Control.Monad.Free.Church
data StateMethod s next
= Put s (() -> next)
| Get (s -> next)
@graninas
graninas / ChurchState.hs
Created September 13, 2023 18:53
Some thoughts on merging Church Free and State monad
-- Option 1: State as an eDSL
data StateMethod s next
= Put s (() -> next)
| Get (s -> next)
instance Functor (StateMethod s) where
fmap f (Put st next) = Put st (f . next)
fmap f (Get next) = Get (f . next)
@graninas
graninas / gist:32a2cd52c062c42bccbad9e8b69b6360
Last active September 13, 2023 18:51
Path 2 to implement the State monad in C++ using Church Free
# This is an idea of how to merge the State monad and the Church Free monad
# without interferring with the inner eDSL.
# This code is incomplete and requires a further development.
# The idea is that we pass the state around with the Church Free functions
# as we would do it with a regular State monad.
# The overal concept is based on my Free monadic STM implementation:
# https://github.com/graninas/cpp_stm_free