This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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 () |