Skip to content

Instantly share code, notes, and snippets.

@i-am-tom
i-am-tom / Optics.hs
Created March 8, 2023 11:52
A short workshop on optics
#!/usr/bin/env cabal
{- cabal:
build-depends: base, containers, lens
-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
@i-am-tom
i-am-tom / Main.hs
Created September 22, 2020 20:37
A warning to all
{-# LANGUAGE DataKinds #-}
{-# LANguAGE FlexibleContexts #-}
{-# LAnguaGE FlexibleInstances #-}
{-# LanguagE KindSignatures #-}
{-# language MultiParamTypeClasses #-}
import GHC.TypeLits (Symbol)
class Warning (message :: Symbol) x
instance Warning (message :: Symbol) x
@i-am-tom
i-am-tom / Main.hs
Last active September 22, 2020 20:36
Monoids in the category of thendofunctors
{-# LANguage FlexibleContexts #-}
{-# laNguAGe FlexibleInstances #-}
{-# languAGE FunctionalDependencies #-}
{-# LANguagE RebindableSyntax #-}
{-# LANguAge ScopedTypeVariables #-}
{-# LAnGuage TypeFamilies #-}
{-# LangUaGe UndecidableInstances #-}
module Control.Monad.Search where
import Data.Function ((&))
@i-am-tom
i-am-tom / bot.hs
Last active July 9, 2020 11:59 — forked from geekingfrog/bot.hs
Pour monsieur Charvet
{-# OPTIONS_GHC -Wall -Wextra #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Functor.Product (Product (..))
import Data.Barbie
@i-am-tom
i-am-tom / Main.hs
Created July 6, 2020 16:42
Variadic number functions
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
------------------------------
-- PROBAT
main :: IO ()
@i-am-tom
i-am-tom / Cursed.hs
Created May 22, 2020 07:52
An oldie-but-goldie
{-# OPTIONS_GHC -Wno-missing-methods #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoStarIsType #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE PolyKinds #-}
@i-am-tom
i-am-tom / First_Main.hs
Last active April 25, 2020 20:19
Code from streams!
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
@i-am-tom
i-am-tom / Read.hs
Created December 23, 2019 13:39
Replacing function arguments with `MonadReader` calls.
-----------------------------------------------------------
-- HOW TO ASK FOR HELP AND AVOID ARGUMENTS.
--
-- When we want to use an externally-provided package (such as logging,
-- database connections, etc) in our work code, it might require some initial
-- config that we traditionally store in our environment.
--
-- We might even require something like a database connection or file handler
-- /throughout/ the lifetime of the code, in order to make queries or similar.
--
@i-am-tom
i-am-tom / 01-DependentTypes.idr
Created October 10, 2019 13:59
HaskellX code examples!
module DependentTypes
TypeOf : {t : Type} -> t -> Type
TypeOf {t} _ = t
-- EXAMPLES
eg0 : TypeOf 3 = Integer
eg0 = Refl
@i-am-tom
i-am-tom / Main.hs
Last active June 27, 2019 14:07
Using Higgledy to create parser fallbacks.
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Control.Applicative (Alternative (..))