Skip to content

Instantly share code, notes, and snippets.

@zudov
zudov / haskellx.org
Last active Oct 13, 2017
Attempt to take notes from Haskell eXchange talks
View haskellx.org

Alois Cochard :: Welcome to the Machines

History of data streaming

Problem

We want:

  • interleaving effects
  • constant space/time
  • strong compasability/reusability
  • We could try the List, but it doesn’t allow effects
  • We could interleave effects via monads (mapM etc), but no constant space/time then and/or lazy IO, meh
@zudov
zudov / Main.purs
Last active Oct 10, 2016
having-effect, section 1, first-class-functions
View Main.purs
-- | Some exercising for http://okmij.org/ftp/Computation/having-effect.html
module Main where
import Control.Monad.Eff.Console
import Control.Bind (bind)
import Data.Boolean (otherwise)
import Data.Eq ((==))
import Data.Semigroup ((<>))
@zudov
zudov / AffEventuallyPromises.md
Last active Jun 17, 2016
Aff vs. Promises vs. Eventual values.
View AffEventuallyPromises.md

I recently read this interesting post about eventual values. One thing that struck me and which I failed to understand is:

  • Eventual Values can be interacted with like normal values.
  • If an Eventual Value is part of a simple value operation, then that expression resolves to a new Eventual > Value which resolves when all its Eventual Values are resolved.

If I understood the author correctly, that is supposed to be solving several problems:

  1. "I don’t know if this is a Promise or not" (I don't know if it's the resolved result of the action, or the action itself).
  2. "I’d really like to write code that interacts with values, and not Promises, and leave the machinery to the computer to work out".
View keybase.md

Keybase proof

I hereby claim:

  • I am zudov on github.
  • I am zudov (https://keybase.io/zudov) on keybase.
  • I have a public key ASBCMjt4P9UCqUn1lR9fvFcKdpAqNYRT5c1OX1ZdVmmh6Ao

To claim this, I am signing this object:

@zudov
zudov / ConstraintFunctor.hs
Last active Dec 29, 2015
ConstraintKinds, Functor, Set
View ConstraintFunctor.hs
-- | https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}
import Prelude hiding (Functor(..))
import Data.Set (Set)
import qualified Data.Set as Set
import GHC.Exts (Constraint)
class Functor f where
type Object f a :: Constraint
@zudov
zudov / Cycle-IO.md
Last active Dec 29, 2015
Cycle's approach to handling the IO
View Cycle-IO.md

Cycle.js approach to handling IO looks similar to how it was done in earlier FRP implementations. That seems to be an independent discovery, and that's always even better.

Yampa provides a function reactimate:

:: IO a	-- ^ IO initialization action
-> (Bool -> IO (DTime, Maybe a)) -- ^ IO input sensing action
-> (Bool -> b -> IO Bool)        -- ^ IO actuaction (output processing) action
-> SF a b	-- ^ Signal function
@zudov
zudov / minisodium_1.purs
Last active Sep 15, 2015
MiniSodium v1
View minisodium_1.purs
module MiniSodium where
import Prelude
import Data.Maybe
import Control.Apply
import Control.Bind
data Stream m a = Stream { sample :: m (Maybe a) }
runStream (Stream s) = s
@zudov
zudov / BodyEditorLoader.java
Last active May 13, 2019
That is a version of loader for physic-body-editor that works with new JSON API from libgdx nightlies.
View BodyEditorLoader.java
package aurelienribon.bodyeditor;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;
@zudov
zudov / Cropper.java
Last active Oct 21, 2018
Crop image using javacv.
View Cropper.java
import static com.googlecode.javacv.cpp.opencv_core.cvCopy;
import static com.googlecode.javacv.cpp.opencv_core.cvCreateImage;
import static com.googlecode.javacv.cpp.opencv_core.cvGetSize;
import static com.googlecode.javacv.cpp.opencv_core.cvSetImageROI;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;
import com.googlecode.javacv.cpp.opencv_core.CvRect;
import com.googlecode.javacv.cpp.opencv_core.IplImage;