I hereby claim:
- I am glguy on github.
- I am glguy (https://keybase.io/glguy) on keybase.
- I have a public key whose fingerprint is 15C3 00D6 96C2 8FD2 BE8E 957D BFDD BB57 E705 C00F
To claim this, I am signing this object:
{-# Language DeriveDataTypeable #-} | |
module GHash where | |
import Data.Generics | |
data HashSkeleton | |
= HashSkeleton Constr [HashSkeleton] | |
| Leaf String -- hash primitive | |
deriving Show |
-- Puzzle explained at https://github.com/dag/all-about-monads/blob/master/examples/example24.hs | |
-- Print each possible solution, one per line | |
main :: IO () | |
main = mapM_ putStrLn solution | |
data Sex = Male | Female deriving (Show, Eq) | |
-- | Boolean implication | |
(==>) :: Bool -> Bool -> Bool |
module Underscore (doUnderscore) where | |
import Language.Haskell.TH | |
import Control.Monad (unless) | |
import Data.Generics (everything, everywhereM, mkM, mkQ) | |
import Data.Monoid (Any(Any)) | |
-- | The placeholder for arguments is the wildcard @_@ | |
placeholder :: Exp | |
placeholder = UnboundVarE (mkName "_") |
{-# Language RankNTypes, TypeInType, ConstraintKinds, GADTs, TypeFamilies, TypeOperators, DataKinds #-} | |
module Tree where | |
import Data.Kind | |
import Data.Bifunctor | |
data SomeN (f :: k) where | |
Base :: f -> SomeN f | |
Step :: (forall a. SomeN (f a)) -> SomeN f |
fn main() { | |
let mut v = vec![false,false,true,false]; | |
for x in &mut v { | |
if *x { break } | |
*x = true; | |
} | |
println!("{:?}", v); |
I hereby claim:
To claim this, I am signing this object:
module MarkSweep where | |
import Data.Array.IO | |
import Data.Word | |
import Data.Bits | |
import Data.Bits.Lens | |
import Data.Foldable (traverse_) | |
import Control.Lens | |
import Control.Monad |
The imports for building the various field-oriented optics are pretty minimal. It's not
until you make a Getter or a Fold that you need to look outside of base
.
This cookbook only covers the field oriented optics and not the constructor oriented ones.
If you want to build a Prism or an Iso without a lens dependency, you should
copy the definition of lens' prism
and iso
combinators and add a profunctors dependency
to your project. Those two combinators are quite self-contained.
import Data.Array | |
import Control.Comonad | |
data Pointer a = Pointer !(Array Int a) !Int | |
deriving (Show) | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE DefaultSignatures #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE UndecidableInstances #-} -- because GHC doesn't know how fundeps work | |
module GenericGenericEach where |