Skip to content

Instantly share code, notes, and snippets.

@nrolland
nrolland / Setup.fsx
Created April 4, 2012 20:46 — forked from ovatsus/Setup.fsx
Script to setup F# Interactive session, loading everything in the current solution. works with many project with a bit of hand cleaning
#if INTERACTIVE
#r "System.Xml"
#r "System.Xml.Linq"
#endif
open System
open System.IO
open System.Xml.Linq
open System.Text.RegularExpressions
@sjoerdvisscher
sjoerdvisscher / adjointFoldPlain.hs
Last active July 26, 2023 13:04
Adjoint folds, using regular Category from base (but custom Functor)
-- http://www.cs.ox.ac.uk/ralf.hinze/SSGIP10/AdjointFolds.pdf
-- http://www.cs.ox.ac.uk/ralf.hinze/publications/SCP-78-11.pdf
-- https://www.cs.ox.ac.uk/people/nicolas.wu/papers/URS.pdf
-- https://arxiv.org/pdf/2202.13633.pdf
{-# LANGUAGE
MultiParamTypeClasses
, FunctionalDependencies
, GADTs
, PolyKinds
@14427
14427 / hkt.rs
Last active February 7, 2024 10:18
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@paolino
paolino / dataflow.hs
Last active April 18, 2021 13:32
A couple of data flow exercises from Doaitse Swiestra (USCS 2016)
{-# language ScopedTypeVariables, ViewPatterns, DeriveFunctor #-}
import Data.Semigroup
data Bin a = Bin a (Bin a) (Bin a) | L a deriving (Eq,Functor, Show)
-- set everywhere the monoidal sum of the tree values, traversing once
setSum :: forall a. Semigroup a => Bin a -> Bin a
setSum t = r where
@RockyRoad29
RockyRoad29 / README.org
Last active May 27, 2022 09:29
Emacs loaded packages exploration tools

Exploring your loaded emacs libraries (spacemacs)

lpkg-explorer

file:lpkg-explorer.el These functions are designed basically for use in a lisp interaction session, where more variants may easily be tailored for your needs .

My main purpose here is to detect potential org-mode conflicts between built-in (typically older) and user local versions.

Copyright 2017 Austin Seipp
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@DarinM223
DarinM223 / typeclassses.md
Last active March 31, 2023 03:35
Typeclasses in Haskell, Scala, and Rust

Type classes

Type classes have some advantages over Java style interfaces. One advantage is the ability to implement functions that do not need to take in an instance of the interface.

For example, (FromString v) takes in a String and returns v, and it doesn't have to take v as a parameter.

Nix Flake MVP

Goals

  • To provide Nix repositories with an easy and standard way to reference other Nix repositories.

  • To allow such references to be queried and updated automatically.

  • To provide a replacement for nix-channel, NIX_PATH and Hydra

#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p "haskellPackages.ghcWithPackages(p: with p; [type-level-sets])"
#! nix-shell -I nixpkgs=channel:nixos-18.03
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
@i-am-tom
i-am-tom / FizzBuzz.hs
Last active June 26, 2023 16:35
Arguably the fastest implementation of FizzBuzz ever written.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnsaturatedTypeFamilies #-}
import GHC.TypeLits
import Prelude hiding (Functor, Semigroup)
type Main = (Fizz <> Buzz) <$> (0 `To` 100)