Skip to content

Instantly share code, notes, and snippets.

View ddellacosta's full-sized avatar

Dave Della Costa ddellacosta

View GitHub Profile
@ddellacosta
ddellacosta / Day18.hs
Last active December 19, 2020 23:18
Advent of Code Day 18 solution in Haskell
{-# LANGUAGE LambdaCase #-}
module Day18_2 where
import Data.Text as T
import Data.Void
import System.IO
import Text.Megaparsec
import Text.Megaparsec.Char
import qualified Text.Megaparsec.Char.Lexer as L
@ddellacosta
ddellacosta / Foo.hs
Created August 3, 2020 00:02
record names via Aeson a la dsal
{-# LANGUAGE DeriveGeneric #-}
module Foo where
import qualified GHC.Generics as G
@ddellacosta
ddellacosta / Fail.purs
Last active December 31, 2019 02:06
deriving newtype instance for UUID fails
module Fail where
import Data.UUID (UUID)
import Simple.JSON as JSON
The question was asked why I (as a programmer who prefers dynamic languages) don't consider static types "worth it". Here
is a short list of what I would need from a type system for it to be truely useful to me:
1) Full type inference. I would really prefer to be able to write:
(defn concat-names [person]
(assoc person :full-name (str (:first-name person)
(:second-name person))))
And have the compiler know that whatever type required and produced from this function was acceptible as long as the
@ddellacosta
ddellacosta / gist:85ddab8a506fa3eeddbc7b1c79877e8b
Created October 27, 2018 18:55
Bool + Product type with associativity?
data Find a = NotFound a | Found a
deriving (Eq, Show)
instance (Semigroup a) => Semigroup (Find a) where
NotFound a <> NotFound b = NotFound (a <> b)
NotFound a <> Found b = Found (a <> b)
Found a <> NotFound b = Found (a <> b)
Found a <> Found b = Found (a <> b)
data A = A { _af :: B, _bs :: [Int] } deriving Show
data B = B { _bf :: Int, _bs1 :: Char } deriving Show
makeLenses ''A
makeLenses ''B
a = A (B 1 'a') []
-- λ> (over bf (+1) . view af) a
@ddellacosta
ddellacosta / my-script.ps1
Created January 26, 2018 17:35
powershell newbie on Mac OS X
New-Object : A parameter cannot be found that matches parameter name 'COMObject'.
At /Users/ddellacosta/my-script.ps1:202 char:28
+ $shellApp = New-Object -COMObject "Shell.Application"
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
var ReactDates =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])

Keybase proof

I hereby claim:

  • I am ddellacosta on github.
  • I am ddellacosta (https://keybase.io/ddellacosta) on keybase.
  • I have a public key whose fingerprint is 5146 F427 F414 62E7 CB2D 6A5A BAAA 370C 86C3 6DB6

To claim this, I am signing this object:

-- For context, see
-- https://github.com/kqr/gists/blob/master/articles/gentle-introduction-monad-transformers.md#introducing-side-effects
userLogin :: EitherIO LoginError Text
userLogin = do
token <- getToken
case token of
Right domain -> liftIO domain
left -> liftEither left