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 Main where | |
import Control.Monad | |
import Data.List | |
import System.Random | |
import Data.Map (Map) | |
import Data.Bool | |
import Text.Read | |
import Data.Maybe | |
import qualified Data.Map as Map |
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 Main where | |
import Prelude hiding (length, filter) | |
import Data.Text | |
-- Turn on optimizations (-O) to make this `False` | |
wat :: Text -> Bool | |
wat x = length (filter (== ',') x) == 1 |
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 Main where | |
import Control.Monad | |
import Control.Concurrent | |
import Text.Printf | |
import Foreign.C.Types | |
foreign import ccall safe "getchar" c_getchar :: IO CChar |
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
function f (x) | |
print("f: " .. x) | |
return g (x + 1) | |
end | |
function g (x) | |
print("g: " .. x) | |
return f (x + 1) | |
end |
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 TypeFamilies #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE CPP #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
module Main where | |
data Test = Test | |
{ testFoo :: Int | |
, testBar :: Bool | |
} |
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 Assign where | |
import Data.IORef | |
mkSummer :: IO (Int -> Int -> IO Int) | |
mkSummer = do | |
ref <- newIORef 0 | |
return $ \x y -> do | |
val <- readIORef ref |
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 Main where | |
-- ReaderT is a little more useful as an example | |
-- think of it as Reader that can also do IO using | |
-- the `lift` function. | |
import Control.Monad.Reader | |
import Text.Printf | |
type Connection = () |
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 #-} | |
module AesonTag where | |
import Data.Aeson | |
import GHC.Generics | |
data Foo | |
= Bar Int | |
| Quux { tag :: Bool } |
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 Main where | |
import Data.Foldable | |
import Control.Concurrent | |
import Control.Monad | |
import System.IO.Unsafe | |
sleepSort :: [Int] -> [Int] |
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 Main | |
(>>) : Monad m => m a -> m b -> m b | |
ma >> mb = ma >>= \_ => mb | |
forever : Monad m => m a -> m a | |
forever x = x >> forever x | |
main : IO () | |
main = forever (putStrLn "foo") |
NewerOlder