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 DataKinds #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
module Main where |
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
(* 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/*) |
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 StateLangSpec where | |
import Test.Hspec | |
import Data.IORef | |
import Control.Monad.Free.Church | |
data StateMethod s next | |
= Put s (() -> next) | |
| Get (s -> next) |
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
-- 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) |
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
# 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 |
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
# This is a sample of how to implement the State monad with Church Free monad. | |
# This sample is incomplete, but its concept is taken from my Free-monad based STM library. | |
# Consider the library to implement the rest of the code. The idea is the same. | |
# https://github.com/graninas/cpp_stm_free | |
#include <functional> | |
#include <variant> | |
#include <any> |
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 AllowAmbiguousTypes #-} | |
module Test2 where | |
import Control.Monad.Free | |
import Control.Monad | |
data BreadType = Baguette | Toast | |
deriving (Show, Eq, Ord) |
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
// https://www.tutorialspoint.com/online_processingjs_editor.php | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.6/processing.min.js"></script> | |
<script type="application/processing" data-processing-target="pjs"> | |
dW = 4; dH = 20; dWH = dW/2; dHH = dH/2; | |
gSh = dWH/2; r = dW/sqrt(2); fs = 2 * (dH); |
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
https://www.youtube.com/watch?v=fhMVCRWpNVc&ab_channel=%D0%90%D0%B9%D0%A2%D0%B8%D0%91%D0%BE%D1%80%D0%BE%D0%B4%D0%B0 | |
igroykt | |
айтишечка и в африке айтишечка | |
а я питоняш, и пишу на нем код наш | |
иногда на пхп, выдаю я выхлоп кнеш |
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
--ghc 8.0.2 | |
type ThermometerName = String | |
type BarometerName = String | |
data Method | |
= ReadThermometer ThermometerName | |
| ReadBarometer BarometerName | |
| ReportTemperature | |
| ReportAtmospherePressure |
NewerOlder