Skip to content

Instantly share code, notes, and snippets.

View bananu7's full-sized avatar
🏍️

Bartek Banachewicz bananu7

🏍️
View GitHub Profile
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.Reader
class Iso a b where
isoFrom :: a -> b
isoTo :: b -> a
@bananu7
bananu7 / queue.idr
Last active August 29, 2015 14:14 — forked from jozefg/queue.idr
module queue
import Data.Vect
-- Here's the port of the Liquid Haskell blog post on amortized
-- queues. The tricksy bit is that the "amortized" bit depends on
-- laziness. This means that while in the REPL (where Idris is lazy)
-- this is reasonably efficient. It compiles absolutely horribly
-- though because each time push or pop something we rotate the whole
-- damned thing.
// what's the difference between:
var family = new Array();
// and
var family = [];

Keybase proof

I hereby claim:

  • I am bananu7 on github.
  • I am bananu7 (https://keybase.io/bananu7) on keybase.
  • I have a public key whose fingerprint is E3DF E40B 6051 62D1 EAE2 C5BB 8335 A5B1 25F5 A3C5

To claim this, I am signing this object:

-- This:
data GlishaState us libs = GlishaState {
userState :: us,
libraryState :: libs,
window :: G.Window,
drawFn :: DrawFn us
}
-- Action monad parametrized over us and libs
-- Both us and libs hoisted into MonadState for library or client
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto" />
<RowDefinition MinHeight="70"/>
</Grid.RowDefinitions>
std::map<std::string, std::string> parseOptions(std::vector<std::string> const& args) {
std::map<std::string, std::string> options;
auto it = args.begin();
it++; // skip the file name
while(it != args.end()) {
if (it->at(0) == '-') {
std::string key = *it;
--hoistState :: Monad m => S.State s a -> S.StateT s m a
--hoistState = S.StateT . (return .) . S.runState
hoistState :: (Monad m, S.MonadState s m) => S.State s a -> m a
hoistState op = do
x <- S.get
let (r, x') = S.runState op x
S.put x'
return r
int32_t n = 0;
int32_t duty = 99;
int32_t dutyChange = -1;
int32_t pulse = 100;
int32_t pulse_counter = 0;
while(1) { /* Loop forever */
//btns = kb.GetKeys(); /* Read button states */
btns = MyKeyboard_GetKeys();
template<typename T>
auto accumulate(T const& xs,
typename std::iterator_traits<decltype(begin(xs))>::value_type const& v)
-> decltype(std::plus<typename std::iterator_traits<decltype(begin(xs))>::value_type>(*std::begin(xs), *std::begin(xs)))
{
return std::accumulate(std::begin(xs), std::end(xs), v);
}
template<typename T, typename F>
auto accumulate(T const& xs,