Skip to content

Instantly share code, notes, and snippets.

View steshaw's full-sized avatar
👨‍💻
Loves programming languages

Steven Shaw steshaw

👨‍💻
Loves programming languages
View GitHub Profile
@gelisam
gelisam / CouldBe.hs
Last active February 21, 2022 13:16
Keeping track of which errors have and haven't been handled
-- in response to https://www.parsonsmatt.org/2018/11/03/trouble_with_typed_errors.html
{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses #-}
module CouldBe where
import Control.Monad
import Data.Void
-- Here is an alternate, much simpler solution to the problem of keeping track of which errors have
-- and haven't been handled. It doesn't use prisms nor generics, it simply uses the monad
It suffers from similar problems to Scala, where it tries to blend OO concepts in with FP concepts.
Variance is where this flares up terribly because it doesn't provide any explicit support for covariance or contravariance.
You end up with invariance and subtyping in a bunch of places which is not a nice combination.
Protocols like Equatable and Hashable are implemented with compiler magic for arrays and tuples.
Which means that you run into trouble with generic functions that say accept two instances of the same type which is Equatable if you pass an array of ints.
You can't say "for a List if the elements are Equatable the List is equatable" IIRC.
This one annoys me no end as we've had to fudge our way around it several times on the same project.
For some reason that eludes me, Optional<T> is given all sorts of special case syntax ("if let" and "guard let") which is like a crap version of "for yield" from Scala or do notation in Haskell that only works on that.
@mightybyte
mightybyte / haskell-language-extensions.md
Last active August 31, 2023 07:50
A Taxonomy of Haskell Language Extensions

Haskell Language Extension Taxonomy

Caveat: It's just personal opinion, and was written to be a bit provocative and encourage discussion . It is also something that is constantly evolving. Some of the main criteria I used in constructing this taxonomy are age, how widely used it us, and how well understood it is by the average Haskell programmer. These things will change over time.

Aso, this is focused on appropriateness for use in commercial production code bases. If you are not thinking about commercial use with a team of multiple

@jdegoes
jdegoes / fpmax.scala
Created July 13, 2018 03:18
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@dwhitney
dwhitney / README.md
Last active May 17, 2024 09:25
Quick React Native with PureScript
  1. create-react-native-app purescript-app; cd purescript-app

  2. pulp init --force

  3. pulp build

  4. src/Main.js

var React = require("react");
var RN = require("react-native");

exports.text = function(props){
@edolstra
edolstra / nix-lang.md
Last active March 27, 2025 11:36
Nix language changes

This document contains some ideas for additions to the Nix language.

Motivation

The Nix package manager, Nixpkgs and NixOS currently have several problems:

  • Poor discoverability of package options. Package functions have function arguments like enableFoo, but there is no way for the Nix UI to discover them, let alone to provide programmatic ways to
@snoyberg
snoyberg / pvp-compliance.hs
Last active February 24, 2018 04:01
Simple script: does every dependency in library and executable stanzas have an upper bound?
#!/usr/bin/env stack
-- stack --resolver lts-10.3 script --optimize
{-# LANGUAGE OverloadedStrings, NoImplicitPrelude #-}
import ClassyPrelude.Conduit
import Data.Conduit.Tar
import System.Directory
import System.FilePath
import Distribution.Types.CondTree
import Distribution.Types.Dependency
import Distribution.Types.PackageName
@dorchard
dorchard / CBNLambdaEff.hs
Last active November 15, 2018 20:40
A Haskell implementation of the categorical semantics for the effectful CBN lambda calculus
{-# LANGUAGE GADTs, TypeFamilies, EmptyDataDecls #-}
{-
A Haskell-based implementation of the monadic semantics for the
simply-typed Call-By-Name computational lambda calculus, following
Moggi's 'Computational lambda-calculus and monads' (1989) (technical report version)
but for the typed calculus (rather than untyped as in this paper).
Category theory seminar, Programming Languages and Systems group,
@steshaw
steshaw / javascript-fe-frameworks.md
Last active January 7, 2018 11:17
JavaScript frontend frameworks
@eckyputrady
eckyputrady / Pseudo.hs
Last active April 2, 2023 12:07
Haskell Clean Architecture
-----------------------------
-- Domain.hs
type SessionId = Text
type UserId = Text
type User = Text
class (Monad m) => UserRepo m where
getUserById :: UserId -> m User