Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
let {event, map, filter, accumulate, forEach} = require("./frp.js")
let {signal: time, feed} = event()
var encodedTime = map(time, x => new Date(x))
var oddSeconds = filter(encodedTime, time => time.getSeconds() % 2 == 1)
var threeLastTimesWithOddSeconds =
{-# language ExistentialQuantification #-}
{-# language NoMonomorphismRestriction #-}
import Data.List
import Data.List.Utils
data Validate a
= Property String (a -> Bool)
| Any [Validate a]
corecursion(Name, App, Deep, [{C, Before, After} | Stack]) :-
App =.. [app, ctor(C) | Rest],
append([Before, [It], After], Rest),
corecursion(Name, It, Deep, Stack).
corecursion(Name, App, Rest, []) :-
App =.. [app, Name | Rest].
deepest_corecursion(Name, App, Scheme, Stack) :-
@Heimdell
Heimdell / TokenSoup.hs
Last active June 30, 2016 13:07
Condense token stream to application tree using operator fixities. TODO: remove crappiness.
{-# language ScopedTypeVariables, GADTs #-}
import Data.Ord (comparing)
import Data.List
import Data.List.Utils
import Control.Arrow
import Control.Monad
import Control.Monad.Except
@Heimdell
Heimdell / DistinctTriplet.hs
Last active June 24, 2016 17:02
Slow implementations of regular expressions
module DistinctTriplet where
import Data.List (nub)
import Test.QuickCheck
-- used as container to generate 3 distinct values
data DistinctTriplet a = Distinct a a a
deriving (Show)
class Match
def initialize x
@x = x
self
end
def self.of x
Match.new x
end
import Dict exposing (Dict)
import Maybe exposing (withDefault)
import String
import Text
import Signal
import Keyboard
import Char
import Graphics.Element as Element exposing (Element)
import Graphics.Collage as Collage exposing (Form)
{-# language FlexibleInstances, UndecidableInstances, TypeSynonymInstances #-}
import Prelude hiding (mapM)
import Control.Monad.State hiding (mapM)
import Control.Applicative
import Data.Traversable
import Data.Foldable
import Data.Monoid
{-# LANGUAGE OverloadedStrings #-}
import Network.Wreq (post, partFile, responseBody)
import Control.Lens ((^.))
import Data.ByteString.Lazy.Char8 as BS
main = do
@Heimdell
Heimdell / Event.hs
Last active February 17, 2016 12:54
Another try of FRP
{-# LANGUAGE RecursiveDo, ScopedTypeVariables #-}
module Event where
import Control.Monad
import Data.IORef
import Data.Map as Map