Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env polaris
module List = import("../polaris/lib/list.pls")
let filterMap : forall a b. (a -> < Nothing, Just(b) > , List(a)) -> List(b)
let filterMap(f, list) = match list {
[] -> []
(x :: xs) -> match f(x) {
Nothing -> filterMap(f, xs)
Just(y) -> y :: filterMap(f, xs)
@Innf107
Innf107 / insttypes.hs
Last active October 22, 2023 20:57
Fast Map Union and Local Instances Through Instance Types
{-# LANGUAGE GHC2021, FunctionalDependencies, AllowAmbiguousTypes, OverloadedRecordDot, BlockArguments #-}
module Lib where
-- Code accompanying https://prophetlabs.de/posts/insttypes.html
import qualified Data.Map as Map
import Unsafe.Coerce
import Data.Proxy
@Innf107
Innf107 / comefrom.hs
Last active December 2, 2022 19:08
Haskell monadic COMEFROM
{-# LANGUAGE RankNTypes, PatternSynonyms, GADTs, ViewPatterns, LambdaCase, ScopedTypeVariables #-}
module Main where
import Data.Map as Map
import Control.Monad (ap, liftM)
import Data.IORef
data ComeFromOp a where
Line :: Int -> ComeFromOp ()
LiftIO :: IO () -> ComeFromOp ()