Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
@danidiaz
danidiaz / _Haskell_Cabal_hacking_notes.md
Last active June 15, 2021 17:49
Haskell Cabal hacking notes

Cabal hacking notes

{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{- cabal:
build-depends: base
, aeson
, lens
, lens-aeson
, split
, raw-strings-qq
, vector
-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE UnliftedDatatypes, GADTs #-}
module Main where
import Data.Kind
import GHC.Exts
-- type List :: forall {l} . TYPE (BoxedRep l) -> TYPE (BoxedRep l)
--type List :: TYPE (BoxedRep Unlifted) -> TYPE (BoxedRep Unlifted)
data List a :: TYPE (BoxedRep l) where
Nil :: List a
@danidiaz
danidiaz / Main.hs
Created April 3, 2021 17:11
Overlapping instances vs closed type families
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE PolyKinds #-}
@danidiaz
danidiaz / RecordUnionFields.hs
Last active April 3, 2021 12:59
Getting fields from the "union" of two records. Inspired by section 3.1 or Hiromi Ishii's "Witness Me" functional pearl.
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
@danidiaz
danidiaz / DotSetter.hs
Last active November 8, 2021 19:23
Repurposing the "getter dot" of RecordDotSyntax for performing record updates.
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
-- | This is an experiment in using the "getter dot" syntax of the upcoming
@danidiaz
danidiaz / Main.hs
Last active February 17, 2021 07:00
simplistic rlwrap clone in Haskell. To wrap sqlite, invoke it as "hlwrap sqlite3 -interactive" or "hlwrap hist_file -- sqlite3 -interactive".
-- | Invoke it as
-- > hlwrap sqlite3 -interactive
--
-- or
--
-- > hlwrap some_histfile -- sqlite3 -interactive
module Main where
import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.List.Split
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NumDecimals #-}
module Main where
import Control.Concurrent
import Control.Concurrent.Async
import Control.Concurrent.MVar