title | author |
---|---|
Indexed Profunctor optics |
Oleg Grenrus |
This post is a response to the Edward's tweet:
Now try to fit all of the indexed and index-preserving variants. ;) Edward Kmett
title | author |
---|---|
Indexed Profunctor optics |
Oleg Grenrus |
This post is a response to the Edward's tweet:
Now try to fit all of the indexed and index-preserving variants. ;) Edward Kmett
{-# Language PatternSynonyms #-}
{-# Language ViewPatterns #-}
data DMonad m = DMonad
(forall a. a -> m a)
(forall a b. m a -> (a -> m b) -> m b)
(forall a. String -> m a)
pattern Open :: (forall a. a -> [a]) -> (forall a a'. [a] -> (a -> [a']) -> [a']) -> (forall a. String -> [a]) -> xxx
-- buildPatSynDetails, so this is a mempty, even the type | |
-- we generate the same location here. | |
hsConDeclDetails _ = pprPanic "tcLHsBindsCtOrigin" (ppr val_val_binds) | |
-------------------- | |
zonkForeignCall :: FlexibleInfo -> CoreBind | |
-> Maybe FreeVars -- True <=> supplied EndBinds | |
-> RecFlag | |
-> Cts -> ForeignOpt Id |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE DeriveTraversable #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
module Demo where |
import Control.Monad | |
import Data.Maybe | |
import Prelude hiding (any, elem) | |
import Data.Foldable | |
type State = String | |
type Map a b = [(a, b)] | |
-- In Map State (Map Char (m State)), the monad m determines the kind of FSM that is being run. | |
-- If m = [] (or Set), these functions work as a NFA. If m = Maybe, we essentially have a DFA. |
{-# LANGUAGE TemplateHaskell, TypeFamilies, DeriveFunctor, DeriveFoldable, DeriveTraversable, FlexibleInstances #-} | |
{-# LANGUAGE LambdaCase, FlexibleContexts, UndecidableInstances, TypeOperators, DataKinds, MultiParamTypeClasses #-} | |
module Sem where | |
import Data.Algebra | |
import Data.Constraint | |
import Data.Constraint.Class1 | |
import Data.Functor.Free | |
class BaseSem a where |
-- Response to | |
-- https://gist.github.com/sjoerdvisscher/e8ed8ca8f3b6420b4aebe020b9e8e235 | |
-- https://twitter.com/sjoerd_visscher/status/975375241932427265 | |
{-# Language QuantifiedConstraints, TypeOperators, RankNTypes, GADTs, ConstraintKinds, MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, PolyKinds, InstanceSigs #-} | |
import Data.Coerce | |
type f ~> g = forall x. f x -> g x |
let List/replicate = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/replicate in | |
let File = Natural in | |
let Rank = Natural in | |
let Square = { file : File, rank : Rank } in | |
let Move = { from : Square, to : Square } in | |
let Side = < white : {} | black : {} > in | |
let white = < white = {=} | black : {} > in | |
let black = < black = {=} | white : {} > in |
{-# language TypeInType, QuantifiedConstraints, ConstraintKinds, RankNTypes, UndecidableInstances, MultiParamTypeClasses, TypeFamilies, KindSignatures #-} | |
module QC where | |
import Data.Constraint | |
import Data.Functor.Contravariant | |
import Data.Kind | |
import Data.Profunctor | |
type C = (Type -> Type) -> (Type -> Type -> Type) -> Constraint |
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses #-} | |
import Data.Monoid | |
import Data.Monoid.Action | |
import Data.Monoid.MList (SM(..)) | |
import Control.Monad.Trans.Class | |
newtype UpdateT p s m a = UpdateT { runUpdateT :: s -> m (p, a) } |