coda-0.0.1: The coda compiler

Safe HaskellNone
LanguageHaskell2010

Coda.Syntax.Change

Synopsis

Documentation

class Semigroup a => InverseSemigroup a where Source #

a <> inv a <> a = a
inv a <> a <> inv a = inv a

and all idempotents commute and are of the form (a <> inv a) for some a

Minimal complete definition

inv

Methods

inv :: a -> a Source #

Instances

data Partial a Source #

This occupies an uncomfortable middle ground between Maybe and Either

Constructors

OK !a 
Fail Error 

Instances

Monad Partial Source # 

Methods

(>>=) :: Partial a -> (a -> Partial b) -> Partial b #

(>>) :: Partial a -> Partial b -> Partial b #

return :: a -> Partial a #

fail :: String -> Partial a #

Functor Partial Source # 

Methods

fmap :: (a -> b) -> Partial a -> Partial b #

(<$) :: a -> Partial b -> Partial a #

MonadFail Partial Source # 

Methods

fail :: String -> Partial a #

Applicative Partial Source # 

Methods

pure :: a -> Partial a #

(<*>) :: Partial (a -> b) -> Partial a -> Partial b #

liftA2 :: (a -> b -> c) -> Partial a -> Partial b -> Partial c #

(*>) :: Partial a -> Partial b -> Partial b #

(<*) :: Partial a -> Partial b -> Partial a #

Foldable Partial Source # 

Methods

fold :: Monoid m => Partial m -> m #

foldMap :: Monoid m => (a -> m) -> Partial a -> m #

foldr :: (a -> b -> b) -> b -> Partial a -> b #

foldr' :: (a -> b -> b) -> b -> Partial a -> b #

foldl :: (b -> a -> b) -> b -> Partial a -> b #

foldl' :: (b -> a -> b) -> b -> Partial a -> b #

foldr1 :: (a -> a -> a) -> Partial a -> a #

foldl1 :: (a -> a -> a) -> Partial a -> a #

toList :: Partial a -> [a] #

null :: Partial a -> Bool #

length :: Partial a -> Int #

elem :: Eq a => a -> Partial a -> Bool #

maximum :: Ord a => Partial a -> a #

minimum :: Ord a => Partial a -> a #

sum :: Num a => Partial a -> a #

product :: Num a => Partial a -> a #

Traversable Partial Source # 

Methods

traverse :: Applicative f => (a -> f b) -> Partial a -> f (Partial b) #

sequenceA :: Applicative f => Partial (f a) -> f (Partial a) #

mapM :: Monad m => (a -> m b) -> Partial a -> m (Partial b) #

sequence :: Monad m => Partial (m a) -> m (Partial a) #

Alternative Partial Source # 

Methods

empty :: Partial a #

(<|>) :: Partial a -> Partial a -> Partial a #

some :: Partial a -> Partial [a] #

many :: Partial a -> Partial [a] #

MonadPlus Partial Source # 

Methods

mzero :: Partial a #

mplus :: Partial a -> Partial a -> Partial a #

Eq a => Eq (Partial a) Source # 

Methods

(==) :: Partial a -> Partial a -> Bool #

(/=) :: Partial a -> Partial a -> Bool #

Ord a => Ord (Partial a) Source # 

Methods

compare :: Partial a -> Partial a -> Ordering #

(<) :: Partial a -> Partial a -> Bool #

(<=) :: Partial a -> Partial a -> Bool #

(>) :: Partial a -> Partial a -> Bool #

(>=) :: Partial a -> Partial a -> Bool #

max :: Partial a -> Partial a -> Partial a #

min :: Partial a -> Partial a -> Partial a #

Read a => Read (Partial a) Source # 
Show a => Show (Partial a) Source # 

Methods

showsPrec :: Int -> Partial a -> ShowS #

show :: Partial a -> String #

showList :: [Partial a] -> ShowS #

Composable a => Semigroup (Partial a) Source # 

Methods

(<>) :: Partial a -> Partial a -> Partial a #

sconcat :: NonEmpty (Partial a) -> Partial a #

stimes :: Integral b => b -> Partial a -> Partial a #

Composable a => SemigroupWithZero (Partial a) Source # 

Methods

zero :: Partial a Source #

Inverse a => InverseSemigroup (Partial a) Source # 

Methods

inv :: Partial a -> Partial a Source #

total :: Partial a -> a Source #

class Composable a where Source #

Methods

compose :: a -> a -> Partial a Source #

compose :: Semigroup a => a -> a -> Partial a Source #

class (Inverse (Idempotent a), Composable a, Idempotent (Idempotent a) ~ Idempotent a) => Inverse a where Source #

Minimal complete definition

inverse

Associated Types

type Idempotent a :: * Source #

Inverse gives us an inverse category, but the types aren't parameters and are down here at the value level

src and tgt are the source and target mappings, and ident provides us the identity arrows.

Methods

inverse :: a -> a Source #

src :: a -> Idempotent a Source #

src :: Idempotent a ~ a => a -> Idempotent a Source #

tgt :: a -> Idempotent a Source #

tgt :: Idempotent a ~ a => a -> Idempotent a Source #

idd :: Idempotent a -> a Source #

idd :: Idempotent a ~ a => Idempotent a -> a Source #

foldMapWithPos :: forall a m. (Measured a, Monoid m) => (Measure a -> a -> m) -> FingerTree a -> m Source #

class (Measured t, HasDelta (Measure t)) => Splittable t where Source #

Minimal complete definition

splitDelta | takeDelta, dropDelta

Methods

splitDelta :: Delta -> t -> (t, t) Source #

takeDelta :: Delta -> t -> t Source #

dropDelta :: Delta -> t -> t Source #

Instances

Splittable Text Source # 
Splittable Delta Source # 
Splittable Change Source #
c = case splitChange d c of (l, r) -> l <> r
 grade c = case splitChange d c of (l, r) -> grade l + grade r
 delta (fst $ splitChange d c) = max 0 (min d (grade c))
 delta (snd $ splitChange d c) = max 0 (min d (grade c - d))

O(log n)

Splittable Edit Source # 
Splittable a => Splittable (FingerTree a) Source # 

class PP a where Source #

Minimal complete definition

pp

Methods

pp :: a -> (String, String) Source #

Instances

PP Delta Source # 

Methods

pp :: Delta -> (String, String) Source #

PP Change Source # 

Methods

pp :: Change -> (String, String) Source #

PP Edit Source # 

Methods

pp :: Edit -> (String, String) Source #

pretty :: PP a => a -> IO () Source #

data Grade Source #

Constructors

Grade !Delta !Delta 

Instances

Eq Grade Source # 

Methods

(==) :: Grade -> Grade -> Bool #

(/=) :: Grade -> Grade -> Bool #

Num Grade Source # 
Ord Grade Source # 

Methods

compare :: Grade -> Grade -> Ordering #

(<) :: Grade -> Grade -> Bool #

(<=) :: Grade -> Grade -> Bool #

(>) :: Grade -> Grade -> Bool #

(>=) :: Grade -> Grade -> Bool #

max :: Grade -> Grade -> Grade #

min :: Grade -> Grade -> Grade #

Read Grade Source # 
Show Grade Source # 

Methods

showsPrec :: Int -> Grade -> ShowS #

show :: Grade -> String #

showList :: [Grade] -> ShowS #

Monoid Grade Source # 

Methods

mempty :: Grade #

mappend :: Grade -> Grade -> Grade #

mconcat :: [Grade] -> Grade #

Relative Grade Source # 

Methods

rel :: Delta -> Grade -> Grade Source #

HasOrderedDelta Grade Source # 
HasMonoidalDelta Grade Source # 
HasDelta Grade Source # 

Methods

delta :: Grade -> Delta Source #

Inverse Grade Source # 
Composable Grade Source # 
type Idempotent Grade Source # 

data Edit Source #

Constructors

Edit !Delta !Delta !Delta 

Instances

Eq Edit Source # 

Methods

(==) :: Edit -> Edit -> Bool #

(/=) :: Edit -> Edit -> Bool #

Ord Edit Source # 

Methods

compare :: Edit -> Edit -> Ordering #

(<) :: Edit -> Edit -> Bool #

(<=) :: Edit -> Edit -> Bool #

(>) :: Edit -> Edit -> Bool #

(>=) :: Edit -> Edit -> Bool #

max :: Edit -> Edit -> Edit #

min :: Edit -> Edit -> Edit #

Show Edit Source # 

Methods

showsPrec :: Int -> Edit -> ShowS #

show :: Edit -> String #

showList :: [Edit] -> ShowS #

Default Edit Source # 

Methods

def :: Edit

Relative Edit Source # 

Methods

rel :: Delta -> Edit -> Edit Source #

Measured Edit Source # 

Associated Types

type Measure Edit :: * Source #

HasOrderedDelta Edit Source # 
HasDelta Edit Source # 

Methods

delta :: Edit -> Delta Source #

FromEdit Edit Source # 

Methods

fromEdit :: Edit -> Edit Source #

PP Edit Source # 

Methods

pp :: Edit -> (String, String) Source #

Splittable Edit Source # 
type Measure Edit Source # 

class Editable a where Source #

edit e >=> edit (inverseEdit e) >=> edit e = edit e
edit (inverseEdit e) >=> edit e >=> edit (inverseEdit e) = edit (inverseEdit e)

Minimal complete definition

edit

Methods

edit :: Edit -> a -> Partial a Source #

class FromEdit a where Source #

Minimal complete definition

fromEdit

Methods

fromEdit :: Edit -> a Source #

ins :: FromEdit a => Delta -> a Source #

del :: FromEdit a => Delta -> a Source #

cpy :: FromEdit a => Delta -> a Source #

data Change Source #

Invariants:

1) no two edits with 0 spaces between them. they get coalesced into a single edit node

2) all edits have at least one of the finger-trees non-empty

Changes are simplicial morphisms, monotone functions between finite sets of integers that start at 0

Constructors

Change !(FingerTree Edit) !Delta 

Instances

Eq Change Source # 

Methods

(==) :: Change -> Change -> Bool #

(/=) :: Change -> Change -> Bool #

Ord Change Source # 
Show Change Source # 
Semigroup Change Source #

given a change x that will successfully apply to t, and a change y that successfully applies to s concatChange x y successfully applies to (t <> s)

Monoid Change Source # 
Relative Change Source # 

Methods

rel :: Delta -> Change -> Change Source #

Measured Change Source # 

Associated Types

type Measure Change :: * Source #

HasDelta Change Source #

This measures the size of the domain, delta (inv d) measures the codomain

Methods

delta :: Change -> Delta Source #

Changeable Change Source #

change f g provides g . f

FromEdit Change Source # 

Methods

fromEdit :: Edit -> Change Source #

Editable Change Source # 
PP Change Source # 

Methods

pp :: Change -> (String, String) Source #

Splittable Change Source #
c = case splitChange d c of (l, r) -> l <> r
 grade c = case splitChange d c of (l, r) -> grade l + grade r
 delta (fst $ splitChange d c) = max 0 (min d (grade c))
 delta (snd $ splitChange d c) = max 0 (min d (grade c - d))

O(log n)

Inverse Change Source # 
Composable Change Source #

compose f g provides f . g

type Measure Change Source # 
type Idempotent Change Source # 

pattern C0 :: Delta -> Change Source #

pattern CN :: Edit -> FingerTree Edit -> Delta -> Change Source #

newtype App f a Source #

Constructors

App 

Fields

Instances

Functor f => Functor (App f) Source # 

Methods

fmap :: (a -> b) -> App f a -> App f b #

(<$) :: a -> App f b -> App f a #

Applicative f => Applicative (App f) Source # 

Methods

pure :: a -> App f a #

(<*>) :: App f (a -> b) -> App f a -> App f b #

liftA2 :: (a -> b -> c) -> App f a -> App f b -> App f c #

(*>) :: App f a -> App f b -> App f b #

(<*) :: App f a -> App f b -> App f a #

(Applicative f, Monoid a) => Monoid (App f a) Source # 

Methods

mempty :: App f a #

mappend :: App f a -> App f a -> App f a #

mconcat :: [App f a] -> App f a #

class Changeable a where Source #

Minimal complete definition

change

Methods

change :: Change -> a -> Partial a Source #

Instances

Changeable Delta Source #

O(log(min(k,n-k))) where there are n edits, k of which occur before the position in question

Changeable Change Source #

change f g provides g . f

generalize :: Change -> Change Source #

build a strictly more general function that produces the same answer on all accepted inputs.

generalize is idempotent