Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
module Union where
import Control.Monad
import qualified Control.Monad.Reader as MTL
data Union fs (m :: * -> *) x where
Here :: f m x -> Union (f : fs) m x
There :: Union fs m x -> Union (f : fs) m x
module AST where
import Data.Constraint
import Data.Functor.Compose
import Data.Fix
import Data.Text (Text)
import qualified Data.Text as Text
import GHC.TypeLits
{-# language DataKinds #-}
{-# language DerivingStrategies #-}
{-# language DeriveFunctor #-}
{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language FunctionalDependencies #-}
{-# language GADTs #-}
{-# language KindSignatures #-}
{-# language MultiParamTypeClasses #-}
{-# language ScopedTypeVariables #-}
module Weld where
import Control.Arrow
import Data.Bifunctor as B
import Text.PrettyPrint as PP hiding ((<>))
infix 1 \/
module Optics.Core exposing
( Optic
, id
, o
, lens
, prism
, traversal
, view
@Heimdell
Heimdell / Main.hs
Last active September 14, 2020 06:49
CSK machine for lazy language with let-rec and Shift/Reset
{-# language LambdaCase #-}
{-# language BlockArguments #-}
{-# language GADTs #-}
{-# language DataKinds #-}
{-# language TypeApplications #-}
{-# language DuplicateRecordFields #-}
{-|
module type FUNCTOR = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
module type APPLY = sig
include FUNCTOR
val ap : ('a -> 'b) t -> 'a t -> 'b t
end
{- | The union of functors and utilities.
-}
module Union
( -- * Union type
Union(..)
, eliminate
type ('r, 'a) logic = Logic of (('a -> 'r -> 'r) -> 'r -> 'r)
let runLogic : ('r, 'a) logic -> ('a -> 'r -> 'r) -> 'r -> 'r
= fun (Logic run) -> run
let bind : ('r, 'a) logic -> ('a -> ('r, 'b) logic) -> ('r, 'b) logic
= fun (Logic ma) amb ->
Logic <| fun yes no ->
ma (fun a -> runLogic (amb a) yes) no
@Heimdell
Heimdell / Example.fs
Created January 24, 2020 22:11
Zipper in F#
module Example
type fs =
| File of string list
| Dir of (string, fs) Map
type fsKind =
| IsFile
| IsDir