haskellari / lattices

Fine-grained lattice primitives for Haskell
BSD 3-Clause "New" or "Revised" License
35 stars 15 forks source link

Any interest in free structures? #36

Closed ocharles closed 7 years ago

ocharles commented 7 years ago

Things such as

newtype FreeJoinSemilattice a = FreeJoinSemilattice
  { unFreeJoinSemilattice :: forall j. JoinSemiLattice j =>
                                         (a -> j) -> j
  }

liftFreeJoinSemilattice :: a -> FreeJoinSemilattice a
liftFreeJoinSemilattice a = FreeJoinSemilattice (\inj -> inj a)

lowerFreeJoinSemilattice
  :: JoinSemiLattice b
  => FreeJoinSemilattice a -> (a -> b) -> b
lowerFreeJoinSemilattice (FreeJoinSemilattice f) = f

instance Join (FreeJoinSemilattice a) where
  join (FreeJoinSemilattice f) (FreeJoinSemilattice g) =
    FreeJoinSemilattice (\inj -> f inj \/ g inj)
phadej commented 7 years ago

Why not, feel free to make a PR for Algebra.Lattice.Free

Icelandjack commented 7 years ago

Implication constraints cannot come soon enough

ocharles commented 7 years ago

Fixed in https://github.com/phadej/lattices/pull/41