Dear Haskellers,
While trying to understand the interconnection and hierarchy behind
the important typeclasses, I stumbled upon the following question that
I am not able to answer:
There seems to be a hierachy of the type classes, in the sense, that
the more powerfull a class is, the more
I don't understand the final part of the question but here are some
comments for the first part.
I don't like the phrase:
the more powerfull a class is, the more fleixblility you have for
combining them to complex programs
powerfull, more flexibility, complex programs -- are not so precise
Thank you for the comments on the first part. While one can argue
about
the different meanings of powerful and flexible here, that's not the
question. The question is, about showing A = B using wrappers like
Kleisli or Cokleisli:
I can use Kleisli to show that a Monad can do everything an
On Tue, May 28, 2013 at 04:42:35PM +0200, Johannes Gerer wrote:
By the same argument, could'nt I say, that any type class (call it
AnyClass) can do everything a Monad can:
instance AnyClass m = Monad (Cokleilsi m ())
That doesn't say that AnyClass can do anything a Monad can. AnyClass m =
That makes sense. But why does
instance Monad m = ArrowApply (Kleisli m)
show that a Monad can do anything an ArrowApply can (and the two are
thus equivalent)?
On Tue, May 28, 2013 at 5:17 PM, Tom Ellis
tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote:
On Tue, May 28, 2013 at 04:42:35PM
On Tue, May 28, 2013 at 05:21:58PM +0200, Johannes Gerer wrote:
That makes sense. But why does
instance Monad m = ArrowApply (Kleisli m)
show that a Monad can do anything an ArrowApply can (and the two are
thus equivalent)?
I've tried to chase around the equivalence between these two
Ok, now I see a difference, why Kleisli can be used to relate
typeclasses (like Monad and ArrowApply) and Cokleisli can not:
Kleisli m () _ = () - m _ is isomorphic to m _
whereas
Cokleisli m () _ = m _ - () is not.
Can somebody point out the relevant category theoretical concepts,
that are
What about these two very simple type classes. Are they equivalent?
(As Monad and ArrowApply)
(This actually compiles in GHC)
class Pointed f where
pure :: a - f a
class Unit f where
unit :: f a a
newtype UnitPointed f a = UnitPointed f a a
instance Unit f = Pointed (UnitPointed f) where
On Tue, May 28, 2013 at 09:09:48PM +0200, Johannes Gerer wrote:
What about these two very simple type classes. Are they equivalent?
[...]
class Pointed f where
pure :: a - f a
class Unit f where
unit :: f a a
newtype UnitPointed f a = UnitPointed f a a
instance Unit f = Pointed
Dear Tom,
I really appreciate your help, but If I could ask the perfect question
I probably would already know the answer... My example should not
prove anything, instead they collectively show, that I am missing
something. And it is not the fact, that pure f does not depend on f.
If, however,
On Tue, May 28, 2013 at 11:22:22PM +0200, Johannes Gerer wrote:
I have to ask, why was plausability and looking at the actual definition
(not just the types) not important for the other examples.
It would also be important to check the definitions in the other examples
too, but it's hard enough
Thanks everyone, I very much appreciate your help, and I think it did help.
I've spent the last few days implementing a substantial chunk of my system
using each of two different techniques. I've ended up going with and ADT
containing functions closed over the 'thing'. This seems to be the
for your convenience, the correct link:
https://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On 29/01/2013, at 12:43 PM, Bob Hutchison hutch-li...@recursive.ca wrote:
The immediate problem is mapping an input to the system, some json message
containing a reference to the 'thing' (like a key of some kind). I have to
take that reference and find the thing and operate on it. All
Today I thought it was about time to simplify how new 'things' of a certain
kind are added to the system. These things are some a cross between an event
and an assertion of a fact in a rule based system. There are many different
kinds of these things. I already have more than a dozen
Hi,
I'm relatively new to Haskell, and consider myself to be towards the beginner
side of the scale. Nevertheless, I've got this Haskell program I've been
working on that's sitting around 11k lines right now. The pattern has been to
let it grow to then knock it back by 'refactoring' or
If I understand your message well enough, I think you are looking for
GHC's `ExistentialQuantification` extension. Building heterogeneous
collections is a common example of what existential types are useful
for. Take a look at this wiki page [1]; there is an example of how to
accomplish this
On Mon, Jan 28, 2013 at 5:43 PM, Bob Hutchison hutch-li...@recursive.cawrote:
Now, this is how I got caught: it seems to be impossible to have
collections of things with a common type class if they have different
types. How is it that I've written that many lines of code in Haskell and
I'm
Hi!
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
class ToString a where
toString :: a - String
class ToText a where
toText :: a - Text
(I use this with newtype wrapped value types backed by Text or
On 8 March 2012 10:53, Simon Hengel s...@typeful.net wrote:
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
class ToString a where
toString :: a - String
class ToText a where
toText :: a - Text
Text
* Simon Hengel s...@typeful.net [2012-03-08 10:53:15+0100]
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
[...]
How do you guys deal with that? Any thoughts?
If it's fine to depend on FunDeps, you can use ListLike.
On Thu, Mar 08, 2012 at 11:00:34AM +0100, Christopher Done wrote:
On 8 March 2012 10:53, Simon Hengel s...@typeful.net wrote:
When writing library code that should work with both String and Text I
find my self repeatedly introducing classes like:
class ToString a where
toString
On Thu, Mar 08, 2012 at 12:18:56PM +0200, Roman Cheplyaka wrote:
If it's fine to depend on FunDeps, you can use ListLike.
http://hackage.haskell.org/package/ListLike
How would that help with toText?
Cheers,
Simon
___
Haskell-Cafe mailing list
* Simon Hengel s...@typeful.net [2012-03-08 11:48:41+0100]
On Thu, Mar 08, 2012 at 12:18:56PM +0200, Roman Cheplyaka wrote:
If it's fine to depend on FunDeps, you can use ListLike.
http://hackage.haskell.org/package/ListLike
How would that help with toText?
toText = fromListLike
If you just need to go back and forth from String to Text, why do you need
to be generic? pack and unpack from Data.Text do the job.
Plus, in the way of what Christopher said, you can use the
OverloadedStrings extension. You can then use the string syntax at a place
that expects a text:
{-#
On Thu, Mar 08, 2012 at 12:37:31PM +0100, Yves Parès wrote:
If you just need to go back and forth from String to Text, why do you need
to be generic? pack and unpack from Data.Text do the job.
Always going through String or Text may (depending on what your
underlying representation is) be less
On Thu, Mar 08, 2012 at 12:54:13PM +0200, Roman Cheplyaka wrote:
* Simon Hengel s...@typeful.net [2012-03-08 11:48:41+0100]
On Thu, Mar 08, 2012 at 12:18:56PM +0200, Roman Cheplyaka wrote:
If it's fine to depend on FunDeps, you can use ListLike.
http://hackage.haskell.org/package/ListLike
* Simon Hengel s...@typeful.net [2012-03-08 13:20:22+0100]
On Thu, Mar 08, 2012 at 12:54:13PM +0200, Roman Cheplyaka wrote:
* Simon Hengel s...@typeful.net [2012-03-08 11:48:41+0100]
On Thu, Mar 08, 2012 at 12:18:56PM +0200, Roman Cheplyaka wrote:
If it's fine to depend on FunDeps, you
Hi,
recently I tried the Typing Haskell in Haskell library. But I was
wondering why this program type checks:
-- plusMfun is standard '+': Num a = a - a - a
test = let Just classEnv = ( addCoreClasses : addNumClasses )
initialEnv
e = Ap ( Ap (Var +) (Lit $ LitStr 3)) (Lit $ LitStr
This is a question about the use of type classes in Haskell.
I get an error (below) when trying to compile the code (below and at
https://github.com/chrisdew/haskell-sandbox/blob/master/not_working_but_clean.hs
).
As someone just learning Haskell, I have tried following GHC's advice,
but I think
On 14/04/11 13:00, Chris Dew wrote:
class Stream a b c d where
(-) :: a - (b - c) - d
instance Stream (IO d) d (IO c) (IO c) where
f - g = f= g
instance Stream d d (IO c) (IO c) where
f - g = g f
instance Stream d d c c where
x - y = y $ x
I notice that in all
Hi Chris
What does the Stream class *do* though?
class Stream a b c d where
(-) :: a - (b - c) - d
Even with Neil's change its still quite unusual:
class Stream a b c where
(-) :: a - (b - c) - c
In the first formulation there is an input of type a, a function (b -
c) and a result of
@Neil Brown - That did it. It's not the ideal solution, as all -
are 'coerced' into being 'IO x' (if the rightmost term is an 'IO x'.
But it'll do for the time being.
Many thanks,
Chris.
On 14 April 2011 13:50, Neil Brown nc...@kent.ac.uk wrote:
On 14/04/11 13:00, Chris Dew wrote:
class
@Stephen Tetley - The stream class exists simply to allow for the
creation of a - operator which can be used to 'Stream' data through
multiple pure and IO functions, on the way to some form of output.
It's probably not a great idea, as there are more idiomatic solutions
in Haskell - I'm sure
On 14 April 2011 20:35, Chris Dew cms...@gmail.com wrote:
Could you suggest how these constraints could be expressed in the
Haskell type system?
Hi Chris
I'm afriad I'd have to decline - generally in Haskell implicit
lifters are problematic, so it isn't something I'd be looking to
solve.
Thanks, that link's very relevant to what I'm trying. For the time
being I'll accept a partial solution where the last two types are now
the same, and try to improve it when my knowledge of Haskell improves.
I really want (hello - bracket) in (hello - bracket -
putStrLn) to have a type of
Daniel Fischer wrote:
class BEING human = HUMAN human where
Sub-classing is logical implication BEING(human) = HUMAN(human)
All types t that make BEING(t) = true also make HUMAN(t)=true
No, it's the other way round. Every HUMAN is also a BEING, hence
HUMAN(t) = BEING(t)
Could I say
Daniel Fischer wrote:
class BEING human = HUMAN human where
Sub-classing is logical implication BEING(human) = HUMAN(human)
All types t that make BEING(t) = true also make HUMAN(t)=true
No, it's the other way round. Every HUMAN is also a BEING, hence
HUMAN(t) = BEING(t)
Could I say that
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 8/28/10 06:17 , Patrick Browne wrote:
In the light of the above examples how should I interpret the
class-to-subclass relation as logical implication? Is it
a) If BEING then HUMAN (sufficient condition): BEING = HUMAN
b) HUMAN is true only if
Hi,
I am trying to understand type classes and sub-classes in purely logical
terms From the literature I gather that:
1)a type class is a predicate over types (using type variables)
2)type sub-classing is a logical implication between these predicates.
But I feel that 1) and 2) does not give
On Friday 27 August 2010 14:54:53, Patrick Browne wrote:
class BEING human = HUMAN human where
At this point there is no additional functionality is defined for the
subclass HUMAN
Sub-classing is logical implication BEING(human) = HUMAN(human)
All types t that make BEING(t) = true also
Hi Pat,
A proof for the predicate BEING(being) must show that there is an
inhabited type (a type which has values)
Note that in a lazy language like Haskell every type is inhabited by _|
_, that is, bottom the undefined value.
If we find a value for a type that is a proof that a type
Sebastian,
Thanks for your very useful reply.
Does the EQ example below not talk about inhabited types as proofs.
Thanks,
Pat
Sebastian Fischer wrote:
If we find a value for a type that is a proof that a type exists (it is
inhabited) that is a member of the class
I don't understand the
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
Haddock 2.7 supports documenting instance implementations; I don't know
how this works, but according to the Changelog it's available.
--
Ivan Lazar
On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
Haddock 2.7 supports documenting instance implementations; I don't know
how this
Ross Paterson r...@soi.city.ac.uk writes:
On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
Haddock 2.7 supports documenting instance
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
Haddock 2.7 supports documenting instance implementations; I don't know
how this works, but
On Sunday 04 July 2010 14:07:03, Ivan Lazar Miljenovic wrote:
Ross Paterson r...@soi.city.ac.uk writes:
On Sun, Jul 04, 2010 at 09:55:53PM +1000, Ivan Lazar Miljenovic wrote:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
On Sunday 04 July 2010 14:03:51, Ross Paterson wrote:
Now we need to go round and document our instances.
Hmm, it seems only partial: documentation attached to an instance is
shown in the list of instances under a type, but not the list under a
class.
Not much of a problem. Right-click on
2010/7/4 Daniel Fischer daniel.is.fisc...@web.de:
Hmm, it seems only partial: documentation attached to an instance is
shown in the list of instances under a type, but not the list under a
class.
I'm guessing that's to reduce noise...
I'm guessing it might have something to do with the
On Sun, Jul 04, 2010 at 02:32:35PM +0200, Daniel Fischer wrote:
On Sunday 04 July 2010 14:07:03, Ivan Lazar Miljenovic wrote:
Ross Paterson r...@soi.city.ac.uk writes:
Hmm, it seems only partial: documentation attached to an instance is
shown in the list of instances under a type, but not
David Waern david.wa...@gmail.com writes:
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
Haddock 2.7 supports documenting instance
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
David Waern david.wa...@gmail.com writes:
2010/7/4 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com:
Andrew Coppin andrewcop...@btinternet.com writes:
In summary, I think we need to devise a way of better-documenting
class instances.
2010/7/4 Ross Paterson r...@soi.city.ac.uk:
It could be either way: sometimes you define a new class with instances
for existing types, and with the current implementation that produces
no documentation.
(I tested with type, class and instance in the same package.)
Hi Ross, thanks for
2010/7/4 David Waern david.wa...@gmail.com:
2010/7/4 Daniel Fischer daniel.is.fisc...@web.de:
Hmm, it seems only partial: documentation attached to an instance is
shown in the list of instances under a type, but not the list under a
class.
I'm guessing that's to reduce noise...
I'm
David Waern wrote:
I found the bug and fixed it, it's in the latest darcs version
Open Source Works.(tm)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
From Real World Haskell:
data JValue = JString String
| JNumber Double
| JBool Bool
| JNull
| JObject [(String, JValue)]
| JArray [JValue]
deriving (Eq, Ord, Show)
type JSONError = String
class JSON a where
On Tue, 23 Dec 2008, wren ng thornton wrote:
In particular, imagine that you have two different and valid ways to convert
the same type into Foo; which do you choose? With the
continuation/combinator/argument approach this is a non-issue since you can
just pass in the one you need. With
Brian Hurt wrote:
So, style question for people, if I can. I have a certain problem-
basically, I have a bunch of functions which need a special function,
of type a - Foo say. And a bunch of other functions which can define
that function on some type of interest, and then what to call the
So, style question for people, if I can. I have a certain problem-
basically, I have a bunch of functions which need a special function,
of type a - Foo say. And a bunch of other functions which can define
that function on some type of interest, and then what to call the first
batch of
On 2008 Dec 20, at 20:20, Brian Hurt wrote:
class Fooable a where
toFoo :: a - Foo
or I can simply have all the functions which need a toFoo take an
extra
agrument. Performance really isn't that important here, so it's
really
a matter of style- which approach would people prefer in this
On Sat, Dec 20, 2008 at 6:20 PM, Brian Hurt bh...@spnz.org wrote:
So, style question for people, if I can. I have a certain problem-
basically, I have a bunch of functions which need a special function,
of type a - Foo say. And a bunch of other functions which can define
that function on
On Tue, Oct 7, 2008 at 1:13 PM, Roly Perera
[EMAIL PROTECTED] wrote:
Hi,
I'm reasonably well versed in Haskell but fairly new to defining type classes.
In particular I don't really understand how to arrange for all instances of X
to also be instances of Y.
It's quite possibly that my
Hi,
I'm reasonably well versed in Haskell but fairly new to defining type classes.
In particular I don't really understand how to arrange for all instances of X
to also be instances of Y.
It's quite possibly that my question is ill-posed, so I'll make it as concrete
as possible: in the
Hello Roly,
Tuesday, October 7, 2008, 4:13:25 PM, you wrote:
I'm reasonably well versed in Haskell but fairly new to defining type classes.
http://haskell.org/haskellwiki/OOP_vs_type_classes may be useful
--
Best regards,
Bulatmailto:[EMAIL PROTECTED]
Hi Henning,
The numeric prelude was inspiration for a lot of my design. Part of
the reason I didn't use it was because one of my goals is to learn
Haskell better, and I wanted to grapple with these design decisions
myself.
I decided, like IsZeroTestable in the numeric prelude, to make
zero/one
Hi everyone,
I'm working on a computational algebra program and I've run into a problem.
In my program, I have types for instances of algebraic objects, e.g. ZModN
for modular integers, and types for the objects themselves, e.g. ZModNTy for
the ring of modular integers.
Now, I want to subclass
On Wednesday 02 July 2008, Cotton Seed wrote:
Hi everyone,
I'm working on a computational algebra program and I've run into a problem.
In my program, I have types for instances of algebraic objects, e.g. ZModN
for modular integers, and types for the objects themselves, e.g. ZModNTy
for the
Hi Dan,
Thanks! This is exactly what I was looking for.
Cotton
On Wed, Jul 2, 2008 at 9:57 PM, Dan Doel [EMAIL PROTECTED] wrote:
On Wednesday 02 July 2008, Cotton Seed wrote:
Hi everyone,
I'm working on a computational algebra program and I've run into a problem.
In my program, I
On Wed, 2 Jul 2008, Cotton Seed wrote:
Hi everyone,
I'm working on a computational algebra program and I've run into a problem.
In my program, I have types for instances of algebraic objects, e.g. ZModN
for modular integers, and types for the objects themselves, e.g. ZModNTy for
the ring of
I'd like to define several instances of the same type class with the
same type variable instance. Only method instances differ. How can I do
this without writing copies of the type class?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Peter Padawitz wrote:
I'd like to define several instances of the same type class with the
same type variable instance. Only method instances differ. How can I do
this without writing copies of the type class?
newtypes and modules have both been suggested.
I have another suggestion:
Don't!
Lutz Donnerhacke [EMAIL PROTECTED] writes:
* Peter Padawitz wrote:
I'd like to define several instances of the same type class with the
same type variable instance. Only method instances differ. How can I do
this without writing copies of the type class?
Define the type class in a module
* Peter Padawitz wrote:
I'd like to define several instances of the same type class with the
same type variable instance. Only method instances differ. How can I do
this without writing copies of the type class?
Define the type class in a module named MyClass. Define the each instance
in a
Hi, there's something I'm trying to do with type classes that seems to fit very
naturally with my mental model of type classes, but doesn't seem to be
supported by the language. I'm wondering whether I'm missing something, or
whether there's some language extension that could help me or
On Tue, 2007-08-07 at 12:58 +, DavidA wrote:
Hi, there's something I'm trying to do with type classes that seems to fit
very
naturally with my mental model of type classes, but doesn't seem to be
supported by the language. I'm wondering whether I'm missing something, or
whether
DavidA wrote:
Now, what I'd like to do is have Lex and Glex, and any further monomial
orderings I define later, automatically derive Show and Num instances from
Monomial (because it seems like boilerplate to have to define Show and Num
instances by hand). Something like the following (not
Hi,
I'm looking for a type class which checks whether two types are the
same or not. My first guess is:
class Same a b where
same :: a - b - Bool
instance Same a a where
same _ _ = True
instance Same a b where
same _ _ = False
In Hugs this seems to work with overlapping instances (not
At Mon, 16 Apr 2007 13:44:13 +0100,
Neil Mitchell wrote:
Hi,
So my question is if this is safe? Will the compiler always pick the
right one? Is there a better way to do this?
I noticed that the results can be a bit suprising sometimes. See if
you can predict the answers to these (in ghci):
Jeremy Shaw wrote:
I noticed that the results can be a bit suprising sometimes. See if
you can predict the answers to these (in ghci):
Interesting examples. Here's another one that I would find problematic:
*SameType same Nothing (Just xyzzy)
False
*SameType same (Nothing ::
In the thread 'automatic derivation', Joel Reymont is looking for
metaprogramming functionality with which he wants to automatically
derive a parser and a pretty printer for his ADT (which is an AST for a
minilanguage).
I replied showing that a significant amount of the boilerplate could be
Hi!
I'm currently experimenting with a bibliography generation tool for
LaTeX. It will (if it will be finished) use BibTeX databases but
bibliography styles will be written in Haskell. I want styles to be
able to transform database entries into some style specific data type,
so I define
class
Max,
class DatabaseEntry e where
entryLabel :: e - String
formatEntry:: e - String
compareEntries :: e - e - Ordering
Then I define
data Entry = forall a. (DatabaseEntry a) = Entry a
instance DatabaseEntry Entry where
entryLabel (Entry e) = entryLabel e
Title: RE: [Haskell-cafe] Type classes
I suppose you want to define compareEntries like this:
compareEntries (Entry x) (Entry y) = compareEntries x y
An option is to just implement it the following way (Haskell98!):
class DatabaseEntry e where
entryLabel :: e - String
formatEntry :: e
Vasin wrote:
To: haskell-cafe@haskell.org
From: Max Vasin [EMAIL PROTECTED]
Date: Mon, 20 Mar 2006 17:46:43 +0300
Subject: [Haskell-cafe] Type classes
Hi!
I'm currently experimenting with a bibliography generation tool for
LaTeX. It will (if it will be finished) use BibTeX databases
Ralf Lammel wrote:
What you can do is define a dedicated *type code* for composition.
comp = hFoldr (undefined::Comp) (id::Int - Int) test
data Comp
instance Apply Comp (x - y,y - z) (x - z)
where
apply _ (f,g) = g . f
That does it!
Thanks,
Greg Buchholz
I was playing around with the HList library from the paper...
Strongly typed heterogeneous collections
http://homepages.cwi.nl/~ralf/HList/
...and I thought I'd try to fold the composition function (.) through a
heterogeneous list of functions, using hFoldr...
{-# OPTIONS
-Original Message-
From: [EMAIL PROTECTED] [mailto:haskell-cafe-
[EMAIL PROTECTED] On Behalf Of Greg Buchholz
Sent: Sunday, November 06, 2005 7:01 PM
To: haskell-cafe@haskell.org
Subject: [Haskell-cafe] Type classes and hFoldr from HList
I was playing around with the HList library from
Arjun,
AG This class definition is giving me a lot of problems
AG with the successor function:
class (Ord st) = MinimaxState st where
successors :: st - [(action, st)]
terminal :: st - Bool
instance MinimaxState Int where
terminal i = i == 0
successors i = [(1,i+1),
Arjan,
AG I'm curious as to why my class declaration
AG compiles in GHC, as there doesn't seem to
AG be any way to use it.
class (Ord st) = MinimaxState st where
successors :: forall a . st - [(a, st)]
terminal :: st - True
Any implementation of the successors method needs to produce
Arjun,
AG This class definition is giving me a lot of problems
AG with the successor function:
class (Ord st) = MinimaxState st where
successors :: st - [(action, st)]
terminal :: st - Bool
instance MinimaxState Int where
terminal i = i == 0
successors i = [(1,i+1), (-1,i-1)]
I'd rather not do that, but even if I did, the type-variable action
would not be reachable in the terminal function. I could specify a
functional dependency st - action (though I've never used it, it would
be a fun to learn). I'm curious as to why my class declaration
compiles in GHC, as
Arjan,
AG I'm curious as to why my class declaration
AG compiles in GHC, as there doesn't seem to
AG be any way to use it.
class (Ord st) = MinimaxState st where
successors :: forall a . st - [(a, st)]
terminal :: st - True
Any implementation of the successors method needs to produce
How about inserting one more parameter, action, in your class
definition:
class (Ord st) = MinimaxState st action where
successors:: st - [(action,st)]
terminal:: st - Bool
instance MinimaxState Int Int where
terminal i = i == 0
successors i = [(1,i+1), (-1,i-1)]
I'd rather
This class definition is giving me a lot of problems with the successor
function:
class (Ord st) = MinimaxState st where
successors:: st - [(action,st)]
terminal:: st - Bool
A trivial example would be:
instance MinimaxState Int where
terminal i = i == 0
successors i = [(1,i+1), (-1,i-1)]
95 matches
Mail list logo