This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE PartialTypeSignatures #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleContexts #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
module Main (main) where | |
import qualified GI.Gdk as Gdk | |
import qualified GI.Gtk as Gtk | |
import Reactive.Banana.Frameworks | |
import Data.GI.Base (on) | |
import Language.Haskell.Interpreter as Hint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Zipper<'a, T> { | |
up : Vec<&'a mut T>, | |
focus : &'a mut T, | |
down : Vec<&'a mut T>, | |
} | |
impl<'a, T> Zipper<'a, T> { | |
fn focus_n(&'a mut self, n: i32) -> Option<&mut Self> { | |
let mut x = self.focus_top()?; | |
// n focus downs from the top |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
type family Remove v xs where | |
Remove x (x ': xs) = Remove x xs | |
Remove x (y ': xs) = y ': Remove x xs | |
Remove x '[] = '[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
{- ORMOLU_DISABLE -} | |
{- | | |
Write this: | |
@ | |
{-# LANGUAGE ImplicitParams, TemplateHaskell #-} | |
import Data.IORef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-} | |
-- zippers is probably a better answer | |
import Control.Lens | |
import Data.Maybe | |
-- with index | |
data WI m = WI (Index m) m | |
deriving instance (Show m, Show (Index m)) => Show (WI m) | |
mkwi' :: Ixed m => Index m -> m -> WI m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- we can implement drawN_ in terms of drawN, but not the other way around | |
-- | |
drawN_ :: MonadState s m => (forall b. [b] -> m [b]) -> m () | |
drawN_ = drawN | |
drawN :: MonadState s m => ([Card] -> m [Card]) -> m () | |
drawN shuffle = _ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Lens | |
{- | in monopoly deal you have to pay more than you owe, | |
if you don't have exact change | |
Ex. if you have $3, $2 $2 $2, $1 $1 bills, and owe 4: | |
>>> overpay 4 [(3,1),(2,3),(1,2)] | |
[([(1,2),(2,1)],[(2,2),(3,1)],0), | |
([(2,2)],[(1,2),(2,1),(3,1)],0), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Criterion.Main | |
import Criterion | |
import Data.List | |
import Data.Foldable (toList) | |
import Data.Random | |
import Data.Monoid ((<>)) | |
import qualified Data.IntMap as IM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE PartialTypeSignatures #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module HistogramProb where | |
import qualified Data.Map as M | |
import Control.Lens |