Skip to content

Instantly share code, notes, and snippets.

View emlautarom1's full-sized avatar
⛓️

Lautaro Emanuel emlautarom1

⛓️
View GitHub Profile
@NathanHowell
NathanHowell / gist:5435345
Last active September 17, 2022 20:39
Simple Warp server that can be gracefully shutdown over HTTP.
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Control.Concurrent (forkIO)
import Control.Concurrent.STM
import Control.Monad (when)
import Control.Monad.Trans (liftIO)
import Network.HTTP.Types
import Network.Wai as Wai
@staltz
staltz / introrx.md
Last active June 29, 2024 15:58
The introduction to Reactive Programming you've been missing
@kristopherjohnson
kristopherjohnson / sudoku.hs
Last active April 28, 2021 03:47
Sudoku solver in Haskell
#!/usr/bin/env runhaskell
-- Note: For a slight improvement in performance, import the non-portable
-- Data.Array.Unboxed module instead of Data.Array, and change the Board
-- type below to use "UArray" instead of "Array".
import Data.Array
-- Solve the example puzzle specified below
-- TODO: read puzzle from input
main = do
@CMCDragonkai
CMCDragonkai / fold_ideas.md
Last active June 11, 2024 02:53
Haskell: Foldl vs Foldr

Foldl vs Foldr

I like to call foldr as "fold from the right", while foldl is "fold from the left".

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
@mtesseract
mtesseract / haskell-records.md
Last active March 8, 2023 22:25
Working around Haskell's namespace problem for records

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 29, 2024 23:24
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@joshburgess
joshburgess / LensLabels.hs
Created February 12, 2019 14:38 — forked from carymrobbins/LensLabels.hs
Using labels as lenses with GHC 8
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DeriveGeneric #-}
module LensLabels where
import Prelude
import Control.Lens
import Data.Generics.Labels
import GHC.Generics
@jproyo
jproyo / Data.hs
Last active May 19, 2022 16:04
Tagless Final Encoding in Haskell Example
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module Data where
type UserName = String
data DataResult = DataResult String
deriving (Eq, Show)
class Monad m => Cache m where