functional-dependencies

Is there a general way to tell the number of parameters of a function in Haskell?

為{幸葍}努か 提交于 2019-12-07 08:59:50
问题 I can tell the number of parameters of a function with the following code {-#Language MultiParamTypeClasses#-} {-#Language FunctionalDependencies#-} {-#Language UndecidableInstances#-} data Zero data Succ a class Number a instance Number Zero instance (Number a) => Number (Succ a) class NotFunction a instance NotFunction Int instance NotFunction Float instance NotFunction (IO a) class (Number n) => FunctionLevel f n | f -> n where functionLevel :: f -> n instance FunctionLevel Int Zero where

Recursive functional dependency not working

北城以北 提交于 2019-12-07 08:47:42
问题 I'm trying to multiply array of units (from dimensional ) in a phantom type and I'm having trouble with functional dependencies. A simplified version of the problem is the following : I have the following type data F (a:: [*]) = F String Where the string represent an expression in a foreign language and a phantom type representing a list of types. I can do things like x = F "x" :: F '[Double] y = F "(1,3)" :: F '[Int, Int] I managed to implements arithmetics operators like this by creating a

What is the “coverage condition”?

一笑奈何 提交于 2019-12-07 00:37:21
问题 The source for the State transformer in mtl states: -- --------------------------------------------------------------------------- -- Instances for other mtl transformers -- -- All of these instances need UndecidableInstances, -- because they do not satisfy the coverage condition. What is the "coverage condition"? All I can tell is that it has something to do with MTPCs and fundeps. 回答1: Section 7.6.3.2 of the GHC manual tells us what the coverage condition is: The Coverage Condition. For

Learning database normalization, confused about 2NF

点点圈 提交于 2019-12-06 06:19:53
I was looking at this video on normalization on youtube and I have to say I am confused now, I there might be errors in the video even though it has 25 likes and only 1 dislike. Normalization Specifically regarding the 2NF section which can be found at the 5 minute mark. The author says the 'Assignment Description' column depends on the Assignment ID column...yet there are there are different Assignment Descriptions for the same Assignment ID. He then 'normalizes' this table into 2NF by breaking it into two tables...one of them containing only Assignment ID and Assignment Description. And this

algorithm for computing closure of a set of FDs

与世无争的帅哥 提交于 2019-12-06 03:20:48
问题 I'm looking for an easy to understand algorithm to compute (by hand) a closure of a set of functional dependencies. Some sources, including my instructor says I should just play with Armstrong's axioms and see what I can get at. To me, that's not a systematic way about doing it (i.e. easy to miss something). Our course textbook (DB systems - the complete book, 2nd ed) doesn't give an algorithm for this either. 回答1: If by "play" he meant an exhaustive search, then in no way this is not

Lossless decomposition vs Dependency Preservation

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 03:06:09
Does anyone of them implies the other? My logic is that if all dependencies are preserved, then there is no loss of information and similarly, if decomposition is lossless then no functional dependency must have been violated. So essentially, dependency preservation is a way to ensure that your decomposition is lossless. I am having a hard time accepting/denying it. So do both of these guarantee one another or are there cases where one can be achieved without the other? In general these are two independent things: you can have a lossless decomposition without dependency preservation, as well

Converting Functional Dependency class to Type Family instances

萝らか妹 提交于 2019-12-05 22:43:34
Is it possible to create type family instances from a fundep class? For example, let's say that I have the class class A a b | a -> b with some instances (imported an external library) and want to create all corresponding instances for the type family type family A' a :: * such that A' a ~ b iff A a b , without having to manually copy and modify the instances from the external source. How would I do that (if it is possible)? My most promising attempt so far, class A' a where type A'_b a :: * instance forall a b. A a b => A' a where type A'_b a = b gives the error message The RHS of an

Is there a general way to tell the number of parameters of a function in Haskell?

若如初见. 提交于 2019-12-05 13:04:11
I can tell the number of parameters of a function with the following code {-#Language MultiParamTypeClasses#-} {-#Language FunctionalDependencies#-} {-#Language UndecidableInstances#-} data Zero data Succ a class Number a instance Number Zero instance (Number a) => Number (Succ a) class NotFunction a instance NotFunction Int instance NotFunction Float instance NotFunction (IO a) class (Number n) => FunctionLevel f n | f -> n where functionLevel :: f -> n instance FunctionLevel Int Zero where functionLevel = undefined instance FunctionLevel Float Zero where functionLevel = undefined instance

algorithm for computing closure of a set of FDs

我的未来我决定 提交于 2019-12-04 07:53:05
I'm looking for an easy to understand algorithm to compute (by hand) a closure of a set of functional dependencies. Some sources, including my instructor says I should just play with Armstrong's axioms and see what I can get at. To me, that's not a systematic way about doing it (i.e. easy to miss something). Our course textbook (DB systems - the complete book, 2nd ed) doesn't give an algorithm for this either. If by "play" he meant an exhaustive search, then in no way this is not-systematic ;) And a simple solution could look like iterative expansion*) of the set of dependencies on the rule-by

Skipping steps in Normalization?

喜夏-厌秋 提交于 2019-12-04 06:31:11
问题 Just curious: is there some reason why one cannot do all necessary normalizations in a single step? Isnt normalization ultimately the redrawing of the Functional Dependency (FD) graph? We start out with an FD diagram/graph and we want to end up with a graph (vertices are attributes, there is an edge between attributes a,b if b is FD on a ) representing a relation in (Edit) BCNF ? EDIT: What I mean is : we start with a FD graph , which is a graph pairing attributes a,b iff b is FD on A, i.e.,