Re: Monads

2003-12-31 Thread Ken Shan
Mark Carroll <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.cafe: > Omitting the typeclass bit, I'm trying to write something like > (s1 -> s2) -> StateT s1 m () -> StateT s2 m a -> StateT s1 m a > > That is, it sequences two StateT computations, providing a w

Re: Infinite types

2003-12-08 Thread Ken Shan
On 2003-12-08T12:42:46-0800, Jeffrey A. Scofield wrote: > b = () -> (a, b) > [...] > I'm wondering how to tell, as a relative newcomer to > Haskell, that they aren't allowed. I think the rule you're looking for is the following: Don't equate a type variable with something that contains that ty

Re: Hypothetical reasoning in type classes

2003-11-23 Thread Ken Shan
On 2003-11-13T13:19:28-, Simon Peyton-Jones wrote: > | From: [EMAIL PROTECTED] > | > | Has anyone thought about adding hereditary Harrop formulas, in other > | words hypothetical reasoning and universal quantification, to the > | instance contexts in the Hsakell type class system? > > Yes, ab

Hypothetical reasoning in type classes

2003-11-13 Thread Ken Shan
d "(*->*)->?" (aka constructor classes), but also types of kind "(*->?)->(*->?)". But that's for another day... Ken -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig "Hi, my name is Kent, and I let people change my .sig on

Re: Type tree traversals [Re: Modeling multiple inheritance]

2003-11-05 Thread Ken Shan
Brandon Michael Moore <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.cafe: > There are two extensions here: > > More overlapping: [...] > Backtracking search: [...] > > Overloading resolution: [...] I'm sorry if I am getting ahead of Simon or behind of you,

Re: Old alternative syntax for list comprehensions?

2003-07-14 Thread Ken Shan
Peter Pudney <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.cafe: > Did I dream this, or was it > a feature of Miranda*, Gopher or Hugs many years ago? I just wanted to see that asterisk again. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bi

Re: can this be written more easily?

2003-02-22 Thread Ken Shan
On 2003-02-21T13:37:26-0500, Mike T. Machenry wrote: > Eh, state is not possible. This is a recursive state space search. I need > to branch the state of the game and not allow branches to effect others. I see-- so you don't care about performing array updates in place, because you will be copying

Re: newbie questions

2003-01-08 Thread Ken Shan
On 2003-01-08T09:19:10+0200, Max Ischenko wrote: > - To be able to run it both in Hugs and by GHC I need an >`import Data.Char(isSpace) for GHC`. Can this be conditionally >included in a source for GHC only? You could use say the C preprocessor to do this, but a better way to solve your p

Re: Monad Maybe?

2002-09-21 Thread Ken Shan
On 2002-09-21T12:56:13-0700, Russell O'Connor wrote: > case (number g) of > Just n -> Just (show n) > Nothing -> > case (fraction g) of >Just n -> Just (show n) >Nothing -> > case (nimber g) of > Just n -> Just ("*"++(show n)) > Nothing -> Nothing How about something lik

Re: Modification of State Transformer

2002-08-08 Thread Ken Shan
On 2002-08-08T14:11:54-0500, Shawn P. Garbett wrote: > newtype St a s = MkSt (s -> (a, s)) > instance Monad St where This line should say instance Monad (St a) where because it is (St a) that is a Monad, not St by itself. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ke

Infix expressions

2002-07-29 Thread Ken Shan
Hello, In Haskell, backquotes can be used to convert individual identifiers into infix operators, but not complex expressions. For example, [1,2,3] `zip` [4,5,6] is OK, but not [1,2,3] `zipWith (+)` [4,5,6] Is there any reason other than potential confusion when one of the two backqu

Re: newtype/datatype (was efficiency)

2002-01-16 Thread Ken Shan
A while ago, to help myself understand newtype, data, and strictness, I tried to write down how Haskell types correspond to lifted domains. Here is a cleaned-up version of my attempt. I am not sure that what follows is entirely correct -- please point out any errors. I would also appreciate comm

Re: Simple compiler question

2001-07-25 Thread Ken Shan
On 2001-07-25T14:39:06-0400, Mark Carroll wrote: > Do any of the decent Haskell compilers allow you to just type function > definitions at an interpreter prompt and use them in subsequent > interactions, as you'd expect from a Lisp environment? I'm fed up of > editing a tiny file separately and ty

Re: [off-topic] LaTex for [[ ... ]]

2001-06-01 Thread Ken Shan
On 2001-06-01T17:59:25+0100, Ross Paterson wrote: > Here's a negative space hack that gives extensible brackets: write > \Sem{expr} to wrap an expression. (Doubtless someone who knows TeX > could do better.) Ah! Neat. [One wishes that TeX could consider arbitrary code to be delimiter definitio

Re: [off-topic] LaTex for [[ ... ]]

2001-06-01 Thread Ken Shan
On 2001-06-01T08:41:34-0700, Andrew Moran wrote: > There's also \llbracket and \rrbracket, from stmaryrd. They look better than > the negative space hack, IMHO (now all I need is for Alan Jeffrey to write in > and say that \{ll,rr}bracket are implemented with the negative space hack :-) Heh. Ac

Re: Funny type.

2001-05-28 Thread Ken Shan
On 2001-05-27T22:46:37-0500, Jay Cox wrote: > >data S m a = Nil | Cons a (m (S m a)) > > >instance (Show a, Show (m (S m a))) => Show (S m a) where > > show Nil = "Nil" > > show (Cons x y) = "Cons " ++ show x ++ " " ++ show y Here's how I've been handling such situations: data S m a = Ni