Skip to content

Instantly share code, notes, and snippets.

View k-bx's full-sized avatar

Kostia R k-bx

View GitHub Profile
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
import GHC.TypeLits
import Data.Proxy
type family Last (a :: (Nat -> *)) :: Nat
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
import Data.Map
import Data.Text
main :: IO ()
main = do
let m = [("foo", 1), ("bar", 2)]
:: Map Text Int
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario: Backup at certain times
Given I have the time 18:00
Then I run server sync at "5:00"
Scenario: Backup at certain times
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario: Backup at certain times
Given I have the time 18:00
Then I run server sync
Then I run server sync at 5:00
@k-bx
k-bx / dotemacs.el
Created December 19, 2013 23:03
Emacs + Haskell + Multiple same names in TAGS
(defun my-ido-find-tag ()
"Find a tag using ido"
(interactive)
(tags-completion-table)
(let (tag-names)
(mapatoms (lambda (x)
(push (prin1-to-string x t) tag-names))
tags-completion-table)
(etags-select-find (ido-completing-read "Tag: " tag-names nil nil
(thing-at-point 'word)))))
Feature: Compute factorial
In order to play with Lettuce
As beginners
We'll implement factorial
Scenario: Backup at certain times
Given I have the time 18:00
Then I run server sync
Then I run server sync at 5:00
@k-bx
k-bx / dotemacs.el
Last active September 22, 2018 07:27
emacs, EtagsSelect, ido-mode, multiple TAGS search and Haskell
(defun my-ido-find-tag ()
"Find a tag using ido"
(interactive)
(tags-completion-table)
(let (tag-names)
(mapatoms (lambda (x)
(push (prin1-to-string x t) tag-names))
tags-completion-table)
(etags-select-find (ido-completing-read "Tag: " tag-names nil nil
(thing-at-point 'word)))))
@k-bx
k-bx / QuickFactories.hs
Created September 24, 2013 09:57
Factories using QuickCheck
{-# LANGUAGE OverloadedStrings, TemplateHaskell #-}
{-# OPTIONS_GHC -F -pgmFderive -optF-F #-}
import Control.Applicative
import Test.QuickCheck
import Test.QuickCheck (Positive(..))
import Test.QuickCheck.Gen (unGen)
import Data.Text (Text)
import Data.String (fromString, IsString)
@k-bx
k-bx / monad_transformers_play.hs
Created September 8, 2013 20:44
Play with MaybeT monad transformer a bit.
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
import Control.Monad
import Control.Monad.Reader
import Control.Monad.Maybe
import Control.Monad.CatchIO hiding (Handler)
import Control.Monad.Trans
import Prelude hiding (catch)
@k-bx
k-bx / hspec_add_setup.hs
Created July 12, 2013 00:14
HSpec add set-up method
import Test.Hspec (Spec, hspec)
import Test.Hspec.Core (SpecTree (..), fromSpecList, runSpecM)
addSetUp :: IO () -> Spec -> Spec
addSetUp action spec = fromSpecList $ (map addActionToSpecItem (runSpecM spec))
where addActionToSpecItem :: SpecTree -> SpecTree
addActionToSpecItem (SpecGroup s l) = SpecGroup s (map addActionToSpecItem l)
addActionToSpecItem (SpecItem s f) = SpecItem s (\params -> (action >> (f params)))
printStuff :: IO ()