Skip to content

Instantly share code, notes, and snippets.

@dfithian
dfithian / unload.hs
Created November 1, 2022 17:34
Haskell Reflex Window Unload Event
import Control.Lens ((^.))
import Language.Javascript.JSaddle (JSCallAsFunction, MonadJSM, js2, jsg, liftJSM)
import Reflex.Dom (Event, MonadWidget, newTriggerEvent)
onWindowUnload :: MonadWidget t m => m (Event t ())
onWindowUnload = do
(event, trigger) <- newTriggerEvent
let body :: JSCallAsFunction = \_ _ [_event] -> liftIO (trigger ())
void . liftJSM $ jsg "window" ^. js2 "addEventListener" "beforeunload" body
pure event
@dfithian
dfithian / reddit-score.csv
Last active April 13, 2024 10:31
Get Haskell Reddit Data
created dayOfWeek hourOfDay score author title
2021-03-08T17:08:01Z Monday 17 1 micheleriva Haskell in the industry (and community) with Alexander Granin
2021-03-08T15:34:14Z Monday 15 1 mihaela_workshub Higher Order Functions: Lambda calculus, Currying, Maps
2021-03-08T03:10:08Z Monday 3 1 Glittering_Squash_33 Point-free
2021-03-08T01:38:13Z Monday 1 1 Tricky_Celebration37 Entering : by itself in GHCi will run the most recent command you've used
2021-03-05T01:01:52Z Friday 1 8 stanislavb Haskell LibHunt - discover popular Haskell projects based on their mentions on Reddit
2021-03-04T23:18:56Z Thursday 23 7 mitbull420 Would anyone like to read 'Thinking with types' (type level programming book by Sandy Maguire) with me?
2021-03-04T22:57:33Z Thursday 22 3 RingularCirc Typeclasses and similar constructs in languages
2021-03-04T21:26:55Z Thursday 21 98 hsyl20 [Haskell-cafe] Serious bug with Natural in GHC 9.0.1
2021-03-04T21:03:05Z Thursday 21 10 flatmapcatmap Heap object de-duplication for memory savings
@dfithian
dfithian / Shared.Common.TH.hs
Created December 12, 2019 20:54
Servant swagger template haskell
-- |Infer a type constructor by name.
-- **NOTE** Does not give context for applied parameters, so may need to add that later.
extractTypeConstructor :: Name -> Q Type
extractTypeConstructor ty =
reify ty >>= \ case
TyConI (NewtypeD _ n ts _ _ _) | n == ty -> foldr appConstructor (conT n) ts
TyConI (DataD _ n ts _ _ _) | n == ty -> foldr appConstructor (conT n) ts
TyConI (TySynD n _ t) | n == ty -> pure t
other -> fail ("couldn't reify type: " <> show other)
where
#!/bin/bash
set -e
# This if stack-enabled fork of https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh
if [ "$#" -ne 1 ]; then
echo "Usage: scripts/hackage-docs.sh HACKAGE_USER"
exit 1
fi

Rust

Build tooling is hard

  • a lot of figuring out random toolchains, libraries, and linkers
  • doesn't work for macOS directly, so a lot of docker containers for running builds

Memory management

  • passing arguments

Title

Template Haskell is for Haters - Of Boilerplate

Format

Hop Workshop (2h)

Audience

Title

Parameterize your Haskell types! Sometimes.

Format

Educational Session (50m)

Audience

Title

Haskell DJs: Compose a hit with Vinyl

Session Topics

  • Languages
  • Concepts
  • Libraries