Thomas Girod wrote:
class (Eq n, Eq e) = Topo a n e where
empty:: a
empty does not allow to infer the types n and e
nodes:: a - [n]
also nodes leaves the type e undetermined
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#functional-dependencies
Thomas Girod wrote:
Hi there.
I'm trying to define a generic graph type here and don't understand on
one error I get. Here I come.
module Graph
where
class (Eq n, Eq e) = Topo a n e where
empty:: a
nodes:: a - [n]
edges:: a - [e]
This does not work
Unfortunately
http://www.cse.ogi.edu/~mpj/pubs/fundeps.html
is broken.
http://web.cecs.pdx.edu/~mpj/pubs/fundeps.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
. Here
is how I am trying to solve the problem, using multi-parameter type
classes.
class NPProblem inst cert where
validates :: cert - inst - Bool
certificates :: inst - [cert]
decide :: inst - Bool
decide i = any (\x - x `validates` i) $ certificates i
Unfortunately, ghc throws
Joshua Ball wrote:
Here is how I am trying to solve the problem, using multi-parameter
type classes.
class NPProblem inst cert where
validates :: cert - inst - Bool
certificates :: inst - [cert]
decide :: inst - Bool
decide i = any (\x - x `validates` i) $ certificates i
That works. Thanks. I didn't realize you could put types in the
expression itself.
On 12/20/06, Greg Buchholz [EMAIL PROTECTED] wrote:
Joshua Ball wrote:
Here is how I am trying to solve the problem, using multi-parameter
type classes.
class NPProblem inst cert where
validates :: cert
karczma wrote:
Actually, I would like to know what was the purpose of all
that...
I was writing some new code and wanted to break it into two parts,
they should have very little knowledge of each other other than what
methods are available in each (hence the classes). The actual types
of the
On Thu, 19 Aug 2004, Sam Mason wrote:
class Foo t where
encode :: String - t
decode :: t - String
test = decode . encode
This currently fails, because the type checker insists on trying
to figure out what its type should be - even though it shouldn't
be needed.
In
Hi,
I've been getting into Haskell over the past few months and have just
come up against a bit of a brick wall when trying to encapsulate
some of the data structures in my code nicely. Basically what I
want to have, is a type class where one of the intermediate values
is opaque with respect to
On Thu, Aug 19, 2004 at 05:42:10PM +0100, Sam Mason wrote:
Hi,
I've been getting into Haskell over the past few months and have just
come up against a bit of a brick wall when trying to encapsulate
some of the data structures in my code nicely. Basically what I
want to have, is a type
Hi,
I've been getting into Haskell over the past few months and have just
come up against a bit of a brick wall when trying to encapsulate
some of the data structures in my code nicely. Basically what I
want to have, is a type class where one of the intermediate values
is opaque with
Sam Mason writes:
Jon Cast wrote:
The intermediate type /is/ needed---it's a (hidden) parameter to your
`encode' and `decode' functions. Why do you think it shouldn't be?
Because I couldn't see the woods for the trees. I think I had
almost figured out what I was asking (the impossible) before
karczma wrote:
Don't forget that this is the toplevel business, not a universal
disease. GHCi says
Prelude :t (show . read)
(show . read) :: String - String
and doesn't complain. But if you define
bz = show . read
the attempt to load this definition (file: ctest.hs) results in:
|5. In the signature of a class operation, every constraint must
| mention at least one type variable that is not a class type
| variable. Thus:
...
|class C a where
| op :: Eq a = (a,b) - (a,b)
|
| is not OK because the constraint (Eq a)
Simon L Peyton Jones wrote:
GHC 3.02 supports multi-parameter type classes, but I have been
guilty of not documenting precisely what that means.
I've now summarised the extensions, informally but I hope
precisely, at
http://www.dcs.gla.ac.uk/multi-param.html
That does not seem
PS. Could somebody inform me what is the current status of
multi-parametric classes?
GHC 3.01 supports multi-parameter type classes
in more or less the form described in the last section of
"Type classes: an exploration of the design space"
16 matches
Mail list logo