Skip to content

Instantly share code, notes, and snippets.

@andrevdm
andrevdm / reqMultiPartUpload.hs
Created Aug 20, 2021
Haskell req multi-part upload, observed
View reqMultiPartUpload.hs
import Control.Exception.Safe (throwString)
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Text as Txt
import qualified Data.Text.Encoding as TxtE
import qualified Network.HTTP.Client as HC
import qualified Network.HTTP.Client.MultipartFormData as MFD
import Network.HTTP.Req ((/:))
import qualified Network.HTTP.Req as R
import qualified System.FilePath as Fp
import qualified Text.URI as URI
@andrevdm
andrevdm / haskellChunkDownload.hs
Last active Aug 2, 2021
Haskell chunked/streamed file downloads with progress notifications
View haskellChunkDownload.hs
import Data.Conduit ((.|))
import qualified Data.Conduit as C
import qualified Data.Conduit.Combinators as C
import Network.HTTP.Req ((/:))
import qualified Network.HTTP.Req as R
import qualified Network.HTTP.Req.Conduit as R
downloadChunkedUrl
:: FilePath
-> (ByteString -> IO ())
@andrevdm
andrevdm / registry04.hs
Created Mar 13, 2021
Registry with partially applied component and DOT (graphviz) display
View registry04.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
-- {-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
module Lib
( run
) where
@andrevdm
andrevdm / registry03.hs
Created Mar 12, 2021
Registry with parameterised monad
View registry03.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
-- {-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
module Lib
( run
) where
@andrevdm
andrevdm / registry02.hs
Created Mar 12, 2021
Registry with one effect using another
View registry02.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Lib
( run
) where
import Protolude
@andrevdm
andrevdm / registry01.hs
Last active Mar 12, 2021
Basic registry example
View registry01.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Lib
( run
) where
import Protolude
@andrevdm
andrevdm / Main.hs
Last active Jun 22, 2020
Haskell perlin noise terrain (2D ascii) with SDL2 display
View Main.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
module Main (main) where
import Protolude
import Foreign.C.Types (CInt (..))
View apecs_ascii_term_min.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeApplications #-}
@andrevdm
andrevdm / ConcurReplica.hs
Last active Jul 17, 2020
Concur-Replica with static middleware and CSS
View ConcurReplica.hs
import Protolude
import qualified Concur.Core as CC
import qualified Concur.Replica as CR
import qualified Data.Map.Strict as Map
import qualified Data.Text as Txt
import qualified Network.Wai.Handler.Replica as WR
import qualified Network.Wai.Handler.Warp as Wa
import Network.Wai.Middleware.Static ((>->))
import qualified Network.Wai.Middleware.Static as MwS
import qualified Network.WebSockets.Connection as Wsc
@andrevdm
andrevdm / polysemyIntercept.hs
Created Nov 11, 2019
Polysemy intercept e.g
View polysemyIntercept.hs
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}