This file contains 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 OverloadedStrings #-} | |
module GetIn where | |
import Prelude hiding ( lookup ) | |
import Control.Monad ( (<=<) | |
, join | |
) | |
import Data.Aeson ( Value( Array |
This file contains 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 OverloadedStrings #-} | |
module GetIn where | |
import Data.Aeson ( Value( Array | |
, Null | |
, Object | |
) | |
, decode | |
) |
This file contains 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 qualified Data.Set as Set | |
type Row = Int | |
type Col = Int | |
renderSols :: [[(Row, Col)]] -> IO () | |
renderSols = mapM_ (putStrLn . renderQs . Set.fromList) | |
where | |
renderQs queens = unlines $ map renderRow (range maxRow) | |
where |
This file contains 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 DeriveGeneric #-} | |
{-# LANGUAGE OverloadedLabels #-} | |
module SideEffectsExample where | |
import Control.Lens | |
import Control.Monad | |
import Control.Monad.IO.Class | |
import Control.Monad.Trans.State.Lazy | |
import Data.Generics.Labels |
This file contains 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 Scrabble where | |
import Data.List ( sortOn ) | |
import Data.Map.Strict ( Map ) | |
import qualified Data.Map.Strict as Map | |
import System.IO ( hFlush | |
, stdout | |
) | |
main :: IO () |
This file contains 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 InstanceSigs #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
module ParsingFromScratch where | |
import Data.String ( String ) |
This file contains 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 MonadPoker where | |
-- https://old.reddit.com/r/haskell/comments/gru0id/haskell_poker_foldm_monadrandom/ | |
import Control.Monad | |
import Control.Monad.Random | |
import System.Random.Shuffle | |
data Rank | |
= Two |
This file contains 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 RankNTypes #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module Data.Matrix.Lens | |
( col | |
, diag | |
, elemAt | |
, inverted | |
, minor | |
, row |
This file contains 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 TreeNumbering where | |
import Control.Lens | |
import Control.Monad.State | |
import Data.Tree | |
tree_ :: Tree Char | |
tree_ = Node 'd' | |
[ Node 'b' | |
[ Node 'a' [] |
This file contains 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
words'' :: String -> [String] | |
words'' s | |
| s == "" = [] | |
| otherwise = takeWhile (/= ' ') s : words'' (dropWhile (== ' ') (dropWhile (/= ' ') s)) | |
words' :: String -> [String] | |
words' s | |
| w /= "" = w : words' rest | |
| otherwise = [] | |
where |