Skip to content

Instantly share code, notes, and snippets.

View alogic0's full-sized avatar

Oleg Tsybulskyi alogic0

  • Odessa, Ukraine
View GitHub Profile
@alogic0
alogic0 / bootstrap.hs
Last active September 27, 2016 00:57 — forked from ali-abrar/bootstrap.hs
Reflex.Dom and Bootstrap CSS
-- source https://gist.github.com/ali-abrar/080f8696c446c477b007
import Reflex.Dom
import Data.Monoid
main :: IO ()
main = mainWidgetWithHead headWidget bodyWidget
headWidget = do
elAttr "link" ("href" =: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" <> "rel" =: "stylesheet" <> "type" =: "text/css") $ return ()
@alogic0
alogic0 / links.md
Last active January 17, 2025 09:58
Some temporaly web-links
@alogic0
alogic0 / regex2parser.md
Created April 7, 2016 01:44
Tranlation of regex to parser combinator
/a/      => char 'a'
/abcd/   => string "abcd"
            sequence [ char 'a', char 'b', char 'c', char 'd' ]
            (:) <$> char 'a' <*> string "bcd"
            (++) <$> string "ab" <*> string "cd"

/[abcd]/ => oneOf "abcd"
/[^abcd]/ => noneOf "abcd"
/[a-z]/ =&gt; oneOf ['a'..'z']
@alogic0
alogic0 / 2016-01-08-capriotti-vs-roman.md
Last active January 8, 2016 04:26
Free Applicative Functors and regex-applicative

http://www.paolocapriotti.com/assets/applicative.pdf

1.4 Example: applicative parsers The idea that monads are “too flexible” has also been explored, again in the context of parsing, by Swierstra and Duponcheel ([12]), who showed how to improve both performance and error-reporting capabilities of an embedded language for grammars by giving up some of the expressivity of monads. The basic principle is that, by weakening the monadic interface to that of an applicative functor (or, more precisely, an alternative

@alogic0
alogic0 / building-hermit-win7.md
Last active December 27, 2015 00:09
Building hermit on windows 7 with ghc 7.10.2, unsuccessful
git clone https://github.com/ku-fpg/hermit
cd hermit
git checkout 'f0d7b767487'
cabal install --only-dep
cabal configure
cabal build
cabal install
@alogic0
alogic0 / hmatrix-building-win7.md
Last active December 14, 2015 03:53
How to build hmatrix, Haskell package, on Win7
@alogic0
alogic0 / Families.hs
Last active October 4, 2015 22:21
Changing fmaily-names diversity over generations
module Families where
import System.Random
import Control.Monad
import Data.List
numPop = 20
num = numPop `div` 2
type Generation = [Pair]
data Pair = Pair {husband::Person, wife::Person, idFamily::Int}
@alogic0
alogic0 / Nptel_ass2_test_hspec.hs
Created August 19, 2015 15:16
NPTEL Haskell 2015, HSpec test for Assignment 2
module Nptel_ass2_test_hspec where
import Nptel_ass2
import Test.Hspec
main :: IO ()
main = hspec $ do
describe "Assignment 2" $ do
describe "ramanujan" $ do
it "Test Case 1" $ do
@alogic0
alogic0 / Nptel_ass2_test_hunit.hs
Last active August 29, 2015 14:27
NPTEL Haskell 2015, HUnit test for Assignment 2
module Nptel_ass2_test_hunit
where
import Test.HUnit
import Test.Hspec
import Test.Hspec.Contrib.HUnit
-- Name of your file with the assignment
-- without trailing .hs
import Nptel_ass2
@alogic0
alogic0 / fib999.hs
Last active August 29, 2015 14:24
Fibonacci numbers in chunks of decimal part of division 1 by 9999...899...
num48 = 999999999999999999999998999999999999999999999999
strNum24 = replicate 47 '0' ++ show (10 ^ (58*48) `div` num48)
chunks _ [] = []
chunks n xs = let (h, t) = splitAt n xs in h : chunks n t
result24 = putStr $ unlines $ map (unwords . chunks 24) $ chunks 48 strNum24
--------
fibs :: [Integer]
fibs = 0:1: zipWith (+) fibs (tail fibs)