arianvp / generics-mrsop-diff Goto Github PK
View Code? Open in Web Editor NEWTypesafe structural diffing of haskell datratypes using generics
License: Other
Typesafe structural diffing of haskell datratypes using generics
License: Other
Given the definition of Ctxs
:
data Ctx :: (kon -> *) -> [*] -> [[Atom kon]] -> Nat -> * where
Ctx :: Constr c n
-> NPHole ki fam ix (Lkup n c)
-> Ctx ki fam c ix
data Ctxs :: (kon -> *) -> [*] -> [[[Atom kon]]] -> Nat -> Nat -> * where
Nil :: Ctxs ki fam cs ix ix
Cons :: (IsNat ix , IsNat a , IsNat b)
=> Ctx ki fam (Lkup ix cs) b -> Ctxs ki fam cs a ix
-> Ctxs ki fam cs a b
and me wanting to visualize the Constructor the hole is pointing to
We will need to somehow call :
datatypeInfo :: (IsNat ix)
=> Proxy fam -> SNat ix -> DatatypeInfo (Lkup ix codes)
However, When we pattern match on Cons
, and want to call datatypeInfo
,
How do we ever discover the SNat ix
that we need to supply? Because
ix
is existential in Ctxs
we can't call getSNat (Proxy :: Proxy ix)
So there is no what for us to visualize the Constructor inside Ctx
case ctxs of
Nil -> ""
Cons (Ctx c h) ctxs ->
constructorName (constrInfoLkup c (datatypeInfo (Proxy :: Proxy fam)) ????)
I'm trying to deconstruct and pattern match on a Ctxs
and Ctx
in order to visualize a zipper, but Haskell is giving me a hard time.
generics-mrsop-diff/src/Generics/MRSOP/GraphViz/Zipper.hs
Lines 32 to 45 in a930839
gives the following type error:
/home/arian/Documents/UU/Thesis/generics/generics-mrsop-diff/src/Generics/MRSOP/GraphViz/Zipper.hs:33:6: error:
• Could not deduce: Lkup ix codes0 ~ sum
from the context: (IsNat ix, Show1 ki, sum ~ Lkup ix codes,
prod ~ Lkup n sum)
bound by the type signature for:
visualizeNPHole :: forall kon1 (ix :: Nat) (ki :: kon1
-> *) (sum :: [[Atom
kon1]]) (codes :: [[[Atom
kon1]]]) (prod :: [Atom
kon1]) (n :: Nat) (fam :: [*]).
(IsNat ix, Show1 ki, sum ~ Lkup ix codes,
prod ~ Lkup n sum) =>
Constr sum n -> NPHole ki fam ix prod -> [DotSM NodeId]
at src/Generics/MRSOP/GraphViz/Zipper.hs:(33,6)-(36,19)
‘sum’ is a rigid type variable bound by
the type signature for:
visualizeNPHole :: forall kon1 (ix :: Nat) (ki :: kon1
-> *) (sum :: [[Atom
kon1]]) (codes :: [[[Atom
kon1]]]) (prod :: [Atom
kon1]) (n :: Nat) (fam :: [*]).
(IsNat ix, Show1 ki, sum ~ Lkup ix codes, prod ~ Lkup n sum) =>
Constr sum n -> NPHole ki fam ix prod -> [DotSM NodeId]
at src/Generics/MRSOP/GraphViz/Zipper.hs:(33,6)-(36,19)
• In the ambiguity check for ‘visualizeNPHole’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
In the type signature:
visualizeNPHole :: (IsNat ix,
Show1 ki,
sum ~ Lkup ix codes,
prod ~ Lkup n sum) =>
Constr sum n -> NPHole ki fam ix prod -> [DotSM NodeId]
|
33 | (IsNat ix, Show1 ki, sum ~ Lkup ix codes, prod ~ Lkup n sum)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.