[Haskell-cafe] Why monad tutorials don't work

2007-08-14 Thread Dan Weston
without getting flak for it... :( Dan Weston [1] http://www.soi.city.ac.uk/~ross/papers/Applicative.html Lanny Ripple wrote: Having just gone through all the tutorials and things (again but this time I think it stuck) the Haskell community is on the wrong track as far as teaching Monads to new

Re: [Haskell-cafe] Re: Re[2]: Why monad tutorials don't work

2007-08-15 Thread Dan Weston
nominate Dan Piponi to write it and eagerly await its release! Dan Weston ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Syntax for lambda case proposal could be \of

2007-08-15 Thread Dan Weston
I came really late to this discussion, so I assume someone has already proposed using (Control.Applicative.|) to select the first matching pattern of an unnamed cased object. Can someone point me to where that was proposed and why it was rejected? Dan Weston Isaac Dupree wrote: Duncan

Re: [Haskell-cafe] Re: Bathroom reading

2007-08-16 Thread Dan Weston
I hate to be a party pooper, but isn't this just: f = foldr (\a z - (a:snd z,fst z)) ([],[]) This takes less time to grok and takes no longer to run. But why stop there? import Control.Arrow swap = snd fst f = foldr (\a - swap first (a:)) ([],[]) Just read this aloud to see what it

Re: [Haskell-cafe] Elevator pitch for Haskell.

2007-09-04 Thread Dan Weston
is needed to understand the strong correlation between intelligence and Haskell addiction. Meanwhile, those at risk should be made to program in teams to suppress their creative drive. Dan Weston Paul Johnson wrote: This page (http://www.npdbd.umn.edu/deliver/elevator.html) has a template

Re: [Haskell-cafe] Re: Elevator pitch for Haskell.

2007-09-06 Thread Dan Weston
for Haskell, like wearing Maxwell's equations on a T-shirt at a Grateful Dead concert! :) Dan Weston Ketil Malde wrote: On Wed, 2007-09-05 at 09:54 -0700, Simon Michael wrote: I agree actually. That picture, while very cool, won't help Haskell marketing one bit. :) Avoid success at all costs

Re: [Haskell-cafe] Is take behaving correctly?

2007-09-12 Thread Dan Weston
for empty lists. So there is at least one good reason for the way zipWith works. Dan Weston Conor McBride wrote: Hi folks On 12 Sep 2007, at 00:38, Brent Yorgey wrote: On 9/11/07, PR Stanley [EMAIL PROTECTED] wrote: Hi take 1000 [1..3] still yields [1,2,3] I thought it was supposed to return

Re: [Haskell-cafe] Composition Operator

2007-09-24 Thread Dan Weston
light than heat. There is a lot more to say about function composition, e.g. it is a monoid operation when applied to functions in a single type (a - a). But this e-mail's long enough, and you've probably already stopped reading :) , so I'll stop here as well. Dan Weston [1] I used

Re: [Haskell-cafe] Composition Operator

2007-09-24 Thread Dan Weston
care which type its second argument is. Sorry for the muddle. Dan Weston Dan Weston wrote: Now you've triggered an addict attack. Remember how Haskell is a gateway drug? Composition (.) may not be an abstract function, but it is very fundamental one (so be wary of redefining the (.) operator

Re: [Haskell-cafe] Composition Operator

2007-09-24 Thread Dan Weston
), every singleton is a zero object [i.e. both initial and final]. I thought I was being safe by distinguishing () as my distinguished element. Where did I go wrong? Dan Weston Stefan O'Rear wrote: On Mon, Sep 24, 2007 at 06:47:05PM -0700, Dan Weston wrote: Of course I should have proofread

Re: [Haskell-cafe] Composition Operator

2007-09-24 Thread Dan Weston
Oh, duh! The only systematically distinguishable value in every type is undefined, but I went and excluded that value from my fake Hask* class. Never mind, I'll stop while I'm behind! :( Dan Weston wrote: Well, I did footnote in my first e-mail that: [1] I used the asterisk in the category

Re: [Haskell-cafe] Desugaring of infix operators is (always?) the wrong way round

2007-09-25 Thread Dan Weston
Wise your proposal is. Too long the desugaring I of languages functional not understanding have labored. Anastrophe the rule should be. Working have I been on a language Yoda that these rules implements it aspires to. If the lojban/loglan schism is any precedent, Yoda will split soon enough

Re: [Haskell-cafe] Pierce on type theory and category theory

2007-09-25 Thread Dan Weston
. Let me give you an example... I defy you to be scared by this book. There are an obscene amount of diagrams illustrating the points as well, along with numerous (and redundant) exercises to make sure you are getting it all. Dan Weston Seth Gordon wrote: Are Benjamin C. Pierce's _Types

Re: [Haskell-cafe] Haskell Cheat Sheet?

2007-09-25 Thread Dan Weston
= fix (+1) which is undefined (and seems to be missing an argument), when invariably its type is in practice restricted to: fix :: ((a - b) - (a - b)) - (a - b) which is much more suggestive (but nowhere to be found in the docs). Dan Weston Don Stewart wrote: evan: Has anybody made (or have

Re: [Haskell-cafe] Haskell Cheat Sheet?

2007-09-26 Thread Dan Weston
It seems no one liked idea #2. I still think fix is the wrong name for this, maybe limit would be better. Dan Weston wrote: One suggestion: Section 3.6 defines a function fix: fix :: Eq x = (x - x) - x - x fix f x = if x == x' then x else fix f x' where x' = f x This confusingly

Re: [Haskell-cafe] Haskell Cheat Sheet?

2007-09-26 Thread Dan Weston
as the standard fix function. Somehow this (admittedly minor) point got lost in the heat of battle. Dan Weston Jonathan Cast wrote: On Wed, 2007-09-26 at 17:09 -0500, Derek Elkins wrote: On Wed, 2007-09-26 at 14:12 -0700, Jonathan Cast wrote: On Wed, 2007-09-26 at 11:43 -0700, Dan Weston wrote

Re: [Haskell-cafe] 'data' syntax - a suggestion

2007-09-27 Thread Dan Weston
Thomas Conway wrote: Although Richard's proposal was simpler, I reckon it's worth discussing whether the where clause should allow normal type/data/newtype declarations, effectively introducing a new scope. There are obviously some type variable quantification and name resolution issues that

Re: [Haskell-cafe] int to bin, bin to int

2007-09-27 Thread Dan Weston
I might be inclined to use data Bin = Zero | One (or at least type Bin = Bool) to let the type system guarantee that you'll only ever have binary digits in your [Bin], not any old integer. Using [Int] is an abstraction leak, inviting people to abuse the representation behind your back.

Re: [Haskell-cafe] Newb: List of nodes in a graph - is there a prettier way?

2007-09-28 Thread Dan Weston
If I haven't mistaken what you're asking for, how about: import Data.Set as S nodes = foldr (\(a,b) - S.insert a . S.insert b) S.empty Torsten Otto wrote: Howdy, I'm working towards Dijkstra's algorithm here and I have a feeling that I could do without the helper function nodesInternal

Re: [Haskell-cafe] Newb: List of nodes in a graph - is there a prettier way?

2007-09-28 Thread Dan Weston
Of course, if you want the result as a list instead of a set: nodeList = S.toList . nodes Dan Weston wrote: If I haven't mistaken what you're asking for, how about: import Data.Set as S nodes = foldr (\(a,b) - S.insert a . S.insert b) S.empty Torsten Otto wrote: Howdy, I'm working

Re: [Haskell-cafe] Assignment, Substitution or what?

2007-10-01 Thread Dan Weston
If you've never been exposed to lambda calculus, then you're in for a real treat! There is no shortage of tutorials on this. If Greek letters and symbol manipulations are not your thing, take a look at http://worrydream.com/AlligatorEggs/ which describes a game that teaches children about

Re: [Haskell-cafe] Re: bizarre memory usage with data.binary

2007-10-02 Thread Dan Weston
Maybe what you are observing is that the operational semantics of undefined is undefined. The program can halt, run forever, use no memory, use all the memory. Although I doubt what GHC does with this code is a random process, I don't think it's too meaningful to ask what are the space usage

Re: [Haskell-cafe] Space and time leaks

2007-10-04 Thread Dan Weston
Ronald Guida wrote: I need some help with space and time leaks. I know of two types of space leak. The first type of leak occurs when a function uses unnecessary stack or heap space. GHCi sum [1..10^6] *** Exception: stack overflow Apparently, the default definition for sum has a space leak.

Re: [Haskell-cafe] Curry and uncurry

2007-10-04 Thread Dan Weston
Here is one trick I have found useful on occasion: Prelude :t let f = undefined :: (Num a) = (a,a) - a in curry f let f = undefined :: (Num a) = (a,a) - a in curry f :: (Num a) = a - a - a undefined (also called bottom) is an element of every type, so if you just need

Re: [Haskell-cafe] New slogan for haskell.org

2007-10-05 Thread Dan Weston
Perl hackers are notoriously good at write-once coding. It's the part where others read what you wrote and make sense of it where Haskell pulls ahead. Albert Y. C. Lai wrote: The Hackathon is a good opportunity to collect preliminary data. Imagine: All other communities are still at the

Re: [Haskell-cafe] New slogan for haskell.org

2007-10-10 Thread Dan Weston
purpose) of haskell-cafe. And of course the justification for this strained material science metaphor! :) Dan Weston Philippa Cowderoy wrote: On Wed, 10 Oct 2007, Andrew Coppin wrote: (I'm less sold on whether you really need to learn a particular dialect well enough to *program

Re: [Haskell-cafe] Re: pi

2007-10-10 Thread Dan Weston
David Benbennick wrote: On 10/10/07, Dan Weston [EMAIL PROTECTED] wrote: Actually, it is a constant: piDecimalExpansion :: String. Where is this constant defined? A translation from piDecimalExpansion :: String to pi :: Floating a = a is already well defined via read :: Read a = String

Re: [Haskell-cafe] symbol type?

2007-10-11 Thread Dan Weston
For a contrary point of view, there is a footnote at the bottom of page 20 in Parsec, a fast combinator parser by Daan Leijen, the creator of Parsec: I have to warn the reader though that experience with the HaskellLight compiler has shown that it hardly pays off in practice to use special

Re: [Haskell-cafe] Fusing foldr's

2007-10-12 Thread Dan Weston
Always check optimizations to make sure they are not pessimizations! Actually, traversing the list twice is very cheap compared to space leakage, and accumulating pairs requires tuple boxing and unboxing which I don't know how to get GHC not to do. Your avg3 (along with several attempts of

Re: [Haskell-cafe] Defining Tree

2007-10-12 Thread Dan Weston
There are many tree types. Take a look at: http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Data-Tree.html PR Stanley wrote: Hi I'm reading the chapter on parsers in the Hutton book. The text refers to the data type tree which doesn't seem to be in prelude. So, I was wondering, what

Re: [Haskell-cafe] more functions to evaluate

2007-10-12 Thread Dan Weston
function is small and easily debuggable, and you can much more easily gauge the optimality of each factored step rather than a bloated function. Dan Weston PR Stanley wrote: Hi folks Any comments and/or criticisms no matter how trivial on the following please: wordSize :: [Int] - Int

Re: [Haskell-cafe] more functions to evaluate

2007-10-12 Thread Dan Weston
I like that name, and will henceforth use it myself until someone sees fit to add it to the Prelude! Maxime Henrion wrote: Isaac Dupree wrote: Dan Weston wrote: applyNtimes :: (a - a) - Int - a - a This sounds like it should be in the library somewhere agree, I've used it a few times

Re: [Haskell-cafe] Equality Question

2007-10-16 Thread Dan Weston
Your intuition that id is related to const is a good one, since id can be defined in terms of const. Here is one of many: id' = flip const const [This is also called a CKK combinator. See http://en.wikipedia.org/wiki/S_combinator#Combinatory_calculi for more examples, such as SKK, SKS, and

Re: [Haskell-cafe] Suspected stupid Haskell Question

2007-10-17 Thread Dan Weston
Oh, why didn't you say you were learning Arrows? Then why not freqs = sort group map (head length) So much more readable, don't you think? ;) Either way, if you run into the dreaded monomorphism restriction: Ambiguous type variable `a' in the constraint: `Ord a' arising from use

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-17 Thread Dan Weston
That is a great tutorial. Thanks! But in the last two sentences of the introduction you say: We just need to find any program with the given type. The existence of a program for the type will be a proof of the corresponding proposition! Maybe you should make explicit that 1) the type is

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-17 Thread Dan Weston
undefined) (Prop undefined) This halts for all p and q since Prop and And are not strict. Dan Weston wrote: That is a great tutorial. Thanks! But in the last two sentences of the introduction you say: We just need to find any program with the given type. The existence of a program

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-17 Thread Dan Weston
not qualify. If all constructors were strict, Prop _|_ = _|_ and all is fine. I am posting this to the haskell-cafe list because I am not at all sure that my understanding is right, and I don't want you to change your tutorial if it's not. Dan Weston Tim Newsham wrote: Also, I was wondering

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-17 Thread Dan Weston
It would seem that this induction on SN requires strictness at every stage. Or am I missing something? Stefan O'Rear wrote: On Wed, Oct 17, 2007 at 03:06:33PM -0700, Dan Weston wrote: 2) the function must halt for all defined arguments fix :: forall p . (p - p) - p fix f = let x = f x in x

Re: [Haskell-cafe] Do you trust Wikipedia?

2007-10-17 Thread Dan Weston
I find the mathematics is more accurate on http://www.conservapedia.com Their facts get checked by the Almighty Himself! ;) Dan Piponi wrote: The mathematics is probably the most reliable part of Wikipedia. -- Dan On 10/17/07, PR Stanley [EMAIL PROTECTED] wrote: Hi Do you trust mathematical

Re: [Haskell-cafe] Re: [Haskell] Announce: generating free theorems, online and offline

2007-10-18 Thread Dan Weston
Now that I look at it, the report notes that: -- Note that (min x y, max x y) = (x,y) or (y,x) but never says that this requirement is mandatory. That's because the comment applies only to the default implementation, not in general. The report does require that The Ord class is used

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-18 Thread Dan Weston
, Oct 17, 2007 at 06:49:24PM -0700, Dan Weston wrote: It would seem that this induction on SN requires strictness at every stage. Or am I missing something? Yes you are missing something. Whether it exists in my message is less certain. First, note that the elements of SN[a] are lambda-terms

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-18 Thread Dan Weston
The function needs to be total. You seem to be using Haskell to execute a function to see if it terminates as a proof of totality. Is that fair? This approach might work for some simple examples, but if the function doesn't terminate immediately then what? I would assume that proof of

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-18 Thread Dan Weston
It was I that he quoted, and now I am totally flummoxed: thm1 :: (a - a) - a thm1 f = let x = f x in x thm1 (const 1) 1 I *thought* that the theorem ((a = a) = a) is not derivable (after all, 0^(0^0) = 0^1 = 0), but it appears somehow that thm1 is a proof of its type. Help, I just

Re: [Haskell-cafe] Do you trust Wikipedia?

2007-10-18 Thread Dan Weston
Some content I have found beneficial in the past when I have stumbled into misunderstandings: http://en.wikipedia.org/wiki/Wikipedia:Assume_good_faith http://en.wikipedia.org/wiki/Wikipedia_talk:Assume_good_faith [EMAIL PROTECTED] wrote: PR Stanley writes: One of the reasons I'm interested in

Re: [Haskell-cafe] Tutorial: Curry-Howard Correspondence

2007-10-22 Thread Dan Weston
Derek and Lennart, Thank you both for your clarifications. Tutorials (and blogs) of the C-H correspondence and the naive (i.e. set-theoretic) categorical descriptions of Haskell are so eager to get to the insights you mention that they gloss too easily over the important role of _|_, a term I

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-24 Thread Dan Weston
Thanks for the concise explanation. I do have one minor question though. -+- A more useful example is ∃a. Show a = a i.e. ∃a.(a - String, a) So, given a value (f,x) :: ∃a.(a - String, a), we can do f x :: String but that's pretty much all we can do. The type is isomorphic to

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-24 Thread Dan Weston
Prelude read 0o232 :: Int 154 Prelude read 0xD29A :: Int 53914 Prelude Maurí­cio wrote: Hi, Are there binary constants in Haskell, as we have, for instance, 0o232 for octal and 0xD29A for hexadecimal? Thanks, Maurício ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Fusing foldr's

2007-10-26 Thread Dan Weston
Type: Intel(R) Xeon(TM) CPU 2.80GHz x32 Clock Speed: 2790 MHZ Josef Svenningsson wrote: Sorry for reacting so late on this mail. I'm digging through some old mails... On 10/12/07, Dan Weston [EMAIL PROTECTED] wrote: Always check optimizations to make sure they are not pessimizations! Actually

Re: [Haskell-cafe] Tim Sweeney and multi-cores .... and Haskell

2007-10-29 Thread Dan Weston
I didn't see anything either. But a search of the site finds one article that mentions Haskell exactly twice (no Tom Sweeney though). An interesting overview of the Language Wars (French translation available as well): The Semicolon Wars: Every programmer knows there is one true programming

Re: [Haskell-cafe] Fibbonachi numbers algorithm work TOO slow.

2007-11-05 Thread Dan Weston
Brent Yorgey wrote: On Nov 5, 2007 5:22 PM, gitulyar [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Please help me. I'm new in Haskell programming, but wrote some things in Scheme. I make so function: fib 1 = 1 fib 2 = 2 fib n = fib (n-1) + fib (n-2) And when I

Re: [Haskell-cafe] Fibbonachi numbers algorithm work TOO slow.

2007-11-05 Thread Dan Weston
I assume you meant fib n=(((1+s)/2)^n-((1-s)/2)^n)/s where s=sqrt 5 Your solution starts to diverge from reality at n = 76: fibs = 0 : 1 : zipWith (+) fibs (tail fibs) Prelude let n = 76 in fibs !! n - round (fib n) 1 [EMAIL PROTECTED] wrote: Andrew Bromage: G'day all. (MIS)Quoting Dan

Re: [Haskell-cafe] Re: speeding up fibonacci with memoizing

2007-11-05 Thread Dan Weston
Throwing in a trace statement in fibaux tells me that fibaux i a b c is not being memoized. If I do map fib [7..9], fibaux counts down to 0 afresh for each of 7, 8, and 9. Ideally, in map fib [0..n], fib (i-2) and fib (i-1) should be memoized and fib i would be evaluated in constant time. This

Re: [Haskell-cafe] Re: Waiting for thread to finish

2007-11-27 Thread Dan Weston
Silly or not, if I compile with -threaded, I always link in the one-liner C file: char *ghc_rts_opts = -N2; so I don't have to remember at runtime whether it should run with 2 cores or not. This just changes the default to 2 cores, so I am still free to run on only one core with the

Re: [Haskell-cafe] nbody (my own attempt) and performance problems

2007-11-28 Thread Dan Weston
Just out of curiosity... --some getter functions pVel !(_,vel,_) = vel pPos !(pos,_,_) = pos pMass !(!_,!_,!mass) = mass What does the !(...) buy you? I thought tuples were already strict by default in patterns (you'd need ~(...) to make them irrefutable), so isn't the above equivalent to:

Re: [Haskell-cafe] New slogan for haskell.org

2007-11-28 Thread Dan Weston
* Static typing, which increases robustness by allowing the compiler to catch many common errors automatically. * Type inference, which deduces types automatically and frees the programmer from writing superfluous type signatures. * Higher order functions, polymorphism, and

Re: [Haskell-cafe] Hit a wall with the type system

2007-11-29 Thread Dan Weston
sin (0.0::Double) 1.0 *Diff diff (\x - x*7+5) (4::Int) 7 Dan Weston Chris Smith wrote: Hi Dan, thanks for answering. Dan Piponi wrote: When you specify that a function has type a - b, you're entering into a bargain. You're saying that whatever object of type a you pass in, you'll get a type b

Re: [Haskell-cafe] Design of a Physics Interface

2007-11-30 Thread Dan Weston
There seems to be three salient benefits of using arrows, as I read the Abstract and Introduction of Benjamin Lerner, Arrow Laws and Efficiency in Yampa, 2003, http://zoo.cs.yale.edu/classes/cs490/03-04a/benjamin.lerner/ 1) The discipline of using arrows assists in avoiding space-leaks The

Re: [Haskell-cafe] distinguish functions from non-functions in a class/instances

2007-12-05 Thread Dan Weston
Wouldn't any isomorphism do (like the Identity monad)? How about nary' f = runIdentity . nary (liftM f) . return Brandon S. Allbery KF8NH wrote: On Dec 5, 2007, at 16:00 , Philipp N. wrote: the odd thing is. you can get this to work, if you have a terminating type as result type (for

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Dan Weston
This is great! Two questions: 1) I want to make sure the function arity matches the list length (as a runtime check). I think I can do this with an arity function using Data.Typeable. I came up with: arity f = a (typeOf f) where a tr | typeRepTyCon tr /= mkTyCon - = 0 | otherwise =

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-07 Thread Dan Weston
), precisely so I don't have to supply it myself. Function arity is (I think) something already known to GHC, so I don't know why we can't get at it too. On Dec 7, 2007 6:21 PM, Dan Weston [EMAIL PROTECTED] wrote: This is great! Two questions: 1) I want to make sure the function arity matches

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-10 Thread Dan Weston
Questioning apfelmus definitely gives me pause, but... id :: a - a-- arity 1 id = ($) :: (a - b) - (a - b) -- arity 2 I agree with the arities given above (but without quotes) and see no ill-definedness to arity. But these are two different classes of functions.

Re: [Haskell-cafe] IO is a bad example for Monads

2007-12-11 Thread Dan Weston
Hans van Thiel wrote: On Tue, 2007-12-11 at 16:56 +0100, Wolfgang Jeltsch wrote: Maybe there are also patient people in the outside world so that we can still expose Haskell to the outside world while not trying to attract quick-and-dirty hackers. ;-) But who are those people? And what harm

Re: [Haskell-cafe] eager/strict eval katas

2007-12-12 Thread Dan Weston
Thomas Hartman wrote: Note that 1 + ··· + n = n * (n+1) / 2, so the average of [1..n] is (n+1) / 2 fair enough. But I believe if I restate the problem so that you need to find the average of an arbitrary list, your clever trick doesn't work and we need eager eval or we blow the stack.

Re: [Haskell-cafe] eager/strict eval katas

2007-12-12 Thread Dan Weston
Dan Weston wrote: scanl above is not strict in its second argument. The data dependencies cause the strictness. Cf: Prelude head ([1,3] ++ head ((scanl undefined undefined) undefined)) 1 The first claim is of course false, nore would the example show it anyway. scanl is not strict in its

[Haskell-cafe] Monads that are Comonads and the role of Adjunction

2007-12-13 Thread Dan Weston
apfelmus wrote: Luke Palmer wrote: Isn't a type which is both a Monad and a Comonad just Identity? (I'm actually not sure, I'm just conjecting) Good idea, but it's not the case. data L a = One a | Cons a (L a) -- non-empty list Maybe I can entice you to elaborate slightly. From

Re: [Haskell-cafe] search Data.Tree.Zipper

2010-03-08 Thread Dan Weston
I think you want find :: Foldable t = (a - Bool) - t a - Maybe a Jian Fan wrote: Hi, There doesn't seem to be a function to search the tree so I come up with following function: searchTree :: (a - Bool) - TreeLoc a - Maybe (TreeLoc a) searchTree pred rootLoc = if pred (getLabel rootLoc)

Re: [Haskell-cafe] newbie question how to pass data

2010-04-19 Thread Dan Weston
First of all, your function func (x,y) s dg =((x*(cos dg) - y*(sin dg)),(x*(sin dg) - y*(cos dg))) does NOT work for type (Float - Float), unless you mean that that is the type of the unused parameter s. Also, your desired type ((Float - Float) - Bool) itself looks suspicious. It must accept

Re: [Haskell-cafe] Type families vs. functional dependencies -- how to express something

2010-05-18 Thread Dan Weston
Unifying those two types by hand, I get: P (A t - B a) ~ P (B a) Maybe the problem is that type families (and associated types, their class cousins) are not injective: P x ~ P y does not imply that x ~ y. Maybe you need a data type (with appropriate wrapping and unwrapping) to ensure

Re: [Haskell-cafe] Deducing a type signature

2010-05-19 Thread Dan Weston
(i) strange f g = g (f g) Assume g :: a - b. Then f :: (a - b) - c. But since g :: a - b, f g :: a, so c = a. Therefore, f :: (a - b) - a, and g (f g) :: a. Therefore, strange :: ((a - b) - a) - (a - b) - a. Almost. The return type of strange is the same as the return type of g (the

Re: [Haskell-cafe] function types as instances of Num

2006-10-26 Thread Dan Weston
How about: {-# OPTIONS -fglasgow-exts #-} import Control.Arrow type Alpha alpha = alpha - (Integer,alpha) test = square . (lit 4) lit :: Integer - Alpha alpha lit val stack= (val, stack) instance Eq (Alpha alpha) where x == y = uncurry (==) . (fst . x fst . y) $ undefined instance

Re: [Haskell-cafe] function types as instances of Num

2006-10-26 Thread Dan Weston
You need to monomorphize the result before printing: main = print $ ((square . 4) :: Alpha ()) Presumably you will apply (square . 4) at some point to a concrete state at some point, and you wouldn't need to provide the type explicitly. Greg Buchholz wrote: Dan Weston wrote: How about

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread Dan Weston
I didn't see any other replies and didn't want to leave you hanging, so... Three hints: 1) you are testing every integer = 2 as a divisor when you only need to test prime numbers = floor(sqrt(n)) 2) Since for all n 2, floor(sqrt(n)) n, you can use the very primes you are generating in the

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread Dan Weston
of (takeWhile (= n) squarePrimes). I haven't tested whether this is actually faster or slower than using sqrt, though! Math functions take only time, but lists require memory allocation. Dan Weston wrote: I didn't see any other replies and didn't want to leave you hanging, so... Three hints: 1) you

[Haskell-cafe] Re: Fractional/negative fixity?

2006-11-07 Thread Dan Weston
??? Modules that import this module get the default fixity from the source. Summary: fixity at definition is exported, fixity on import is locally remapped but not reexported. Better is the enemy of the good -- Voltaire Simple, powerful, minimal. Any takers? Dan Dan Weston wrote: Here's

Re: [Haskell-cafe] How to get subset of a list?

2006-11-30 Thread Dan Weston
Your curious example suggests you might be solving a more specialized problem, like selecting the diagonal of a flattened matrix. In this case, there are much better (and more efficient) data structures that enforce invariants (like squareness of a matrix), if that is what you in fact are

[Haskell-cafe] Num is such a fat and greedy class

2006-12-08 Thread Dan Weston
The following observations are not new, insightful, or gracious, but I was lusting after the innocent +,-,* operators for my own evil ends and was mildly curious why... Num is such a fat and greedy class. If you want to marry Cinderella, you have to take her ugly stepsisters too. 1) Groups may

Re: [Haskell-cafe] Re: A suggestion for the next high profile Haskell project

2006-12-19 Thread Dan Weston
Maybe we should take to heart lessons learned from the Erlang development experience in Joe Armstrong's Erlang Tutorial: 1 Concentrate on essential features 2 You need a protector 3 You will never displace an existing technology if it works -- Wait for the failures 4 Move quickly into

Re: [Haskell-cafe] FD problem in GHC 6.6

2006-12-19 Thread Dan Weston
instance CommandFunction (Sh st ()) st where ^ I think your first argument (on which the second has a functional dependence) does not determine the second argument, since it makes use of st in the first argument. This strikes me as a likely place to begin. Dan

Re: [Haskell-cafe] Showing the 1 element tuple

2006-12-22 Thread Dan Weston
More generally, is there an operator version of dotted pair notation (gasp, did I just lisp?) that works like: data Tuple a b = () | Tuple a b ()== () ( ) 1 == Tuple 1 () (2,'a',hello) == Tuple 2 (Tuple 'a' (Tuple hello ())) And is there anyway in Haskell to restrict the type definition

Re: [Haskell-cafe] Re: Channel9 Interview: Software Composability and theFu ture of Languages

2007-01-31 Thread Dan Weston
it. I for one think that turning the massively parallel, greedily optimizing, lazily evaluating, functional computer/relational database that is our brain into a von Neumann drone is a rather feeble accomplishment by any standard. Dan Weston Magnus Therning wrote: Nneither way may be natural

Re: [Haskell-cafe] Re: Re: nested maybes

2007-02-07 Thread Dan Weston
A way to categorify elements of objects in a cartesian closed category (such as that that sufficiently restricted Haskell takes place in) are to view entities of type A as maps () - A.Mikael Johansson wrote: This rather inconveniently clashes with the fact that A and () - A are two distinct

Re: [Haskell-cafe] A voice in the desert... (Was: Is lazyness make big difference?)

2007-02-15 Thread Dan Weston
have entirely different goals and requirements. Dan Weston Senior Software Engineer Sony Pictures Imageworks NOTE: The opinions and observations expressed here are personal views expressed by me alone and do not necessarily reflect those of Sony Pictures, its subsidiaries, business partners

Re: [Haskell-cafe] Re: Genuine Eratosthenes sieve [Was: Optimization fun]

2007-02-21 Thread Dan Weston
functional data structure would most efficiently accommodate this algorithm, however. Any suggestions? Dan Weston [EMAIL PROTECTED] wrote: Jens Blanck wrote: The point about Eratosthenes's sieve is that it does not specify algorithmically how to find the next number to be crossed. It does

Re: [Haskell-cafe] Splitting Hairs Over Terminology

2007-02-26 Thread Dan Weston
unroll the loop. Variable limits are definitely beyond this definition, since they can only be evaluated at runtime. Dan Weston ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] numeric minimization in Haskell

2007-03-02 Thread Dan Weston
in another language! This is the only argument for using Haskell in the real world that I have found has any traction with management, so I hope people don't disdain it while waiting for the day when the benefits of Haskell will be apparent to all. Dan Dan Piponi wrote: On 2/28/07, Dan

Re: [Haskell-cafe] Draft chapters of Real World Haskell now publicly available

2008-01-23 Thread Dan Weston
I think this points out the benefit (or even the need), given the fast-paced evolution of Haskell and its libraries as a whole, of an evolving online supplement to your book, minimally with errata and code, but also (as publisher resources permit) with intermittently updated appendices on

Re: [Haskell-cafe] anybody can tell me the pronuncation of haskell?

2008-01-28 Thread Dan Weston
Jeremy Shaw wrote: I would say the best description of how I pronounce it (which may or may not be right): is like 'rascal' but with an h. Though, perhaps different people pronounce rascal differently than I do. I think to ease the acceptance of Haskell in the broader world we should spell it

Re: [Haskell-cafe] Re: anybody can tell me the pronuncation of haskell?

2008-01-28 Thread Dan Weston
James Russell wrote: Tim Chevalier catamorphism at gmail.com writes: That is not correct. The second syllable does not rhyme with fell. In fact, the correct pronunciation sounds like hassle with a 'k' inserted between the two syllables of that word. Exactly. But am I the only person who has

Re: [Haskell-cafe] Re: anybody can tell me the pronuncation of?haskell?

2008-01-30 Thread Dan Weston
The opposite can also happen. Tobacco (mid-16th century Spanish) is rendered as tabako in Japanese, in fact a very Japanese-sounding word (perhaps from, ta + hako). This may explain why, unlike almost all foreign words in Japanese that are written in katakana (a sort of simpler-looking

Re: [Haskell-cafe] Simple network client

2008-01-30 Thread Dan Weston
Peter Verswyvelen wrote: main = do cs - getLine putStrLn (Hello ++cs) looks so much like main = do cs - readFile foo writeFile foo cs but in the first one cs is strict, while the second it is lazy... But that's not obvious. Now I'm confused (which happens

Re: [Haskell-cafe] Relevance and applicability of category theory

2008-01-30 Thread Dan Weston
I assume you have read the references in http://www.haskell.org/haskellwiki/Research_papers/Monads_and_arrows The penultimate sentence in question 1 below (role of adjoint functors in Haskell monads) was addressed by David Menendez in a recent post to this list:

Re: [Haskell-cafe] Relevance and applicability of category theory

2008-01-31 Thread Dan Weston
Even though you cannot dive into this matter now, maybe when you get time you can update your blog with an explicit embedding of Haskell monads and arrows in your Thrist construction. Concrete examples will help me (and probably others) more quickly see the novelty, increased generality, and

Re: [Haskell-cafe] Relevance and applicability of category theory

2008-01-31 Thread Dan Weston
, since this is already a subject of some interest to many people. Dan Gabor Greif wrote: Am 31.01.2008 um 18:13 schrieb Dan Weston: Even though you cannot dive into this matter now, maybe when you get time you can update your blog with an explicit embedding of Haskell monads and arrows

Re: [Haskell-cafe] fmap vs. liftM

2008-02-05 Thread Dan Weston
Can you do this with a GHC rule? Something like: {-# RULES join_dot_fmap_return/id forall x . join (fmap return x) = x #-} Dan Henning Thielemann wrote: On Tue, 5 Feb 2008, Brandon S. Allbery KF8NH wrote: On Feb 5, 2008, at 8:31 , Henning Thielemann wrote: How do you convince the

Re: [Haskell-cafe] Parameterisations of Monads

2008-02-05 Thread Dan Weston
Matthew, Your SuperMonad seems remarkably similar to Gabor Greif's Thrist datatype [1,2] reported only six days ago on this list [3]. Can you compare/contrast your class approach with his polymorphic type approach? Or have I completely confused the two because of the similar kind of their

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-07 Thread Dan Weston
I know that naming is arbitrary, but... Digits in types seems ugly to me. In this case, it is also redundant. Everyone but FORTRAN programmers counts from 0, not 1. Nat and Pos seem clear. Nat0 could even mean Nat \ {0}, the opposite of what is proposed, so confusion is even increased with

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-07 Thread Dan Weston
This may be a GHC bug, but even though in the module Data.TypeLevel.Num.Reps has the header {-# LANGUAGE EmptyDataDecls, TypeOperators #-} I still get an error with both ghc and ghci version 6.8.2 unless I throw in the -XTypeOperators flag. cat Go.hs import Data.TypeLevel.Num.Reps main =

Re: [Haskell-cafe] Create a list without duplicates from a list with duplicates

2008-02-08 Thread Dan Weston
As noted, (Data.Set.toList . Data.Set.fromList) is the best traditional solution if you don't care about order (or Data.Set.toAscList for a sorted result). If order is important, the new bijective Data.Bimap class http://code.haskell.org/~scook0/haddock/bimap/Data-Bimap.html may be your best

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Dan Weston
Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 11:14 , Stefan Monnier wrote: You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the latter representation should probably be prefered. (...) How 'bout treating :+ as similar to `append' rather than similar to `cons'?

Re: [Haskell-cafe] Re: Implementing fixed-sized vectors (using datatype algebra?)

2008-02-08 Thread Dan Weston
Dan Weston wrote: Brandon S. Allbery KF8NH wrote: On Feb 8, 2008, at 11:14 , Stefan Monnier wrote: You seem to write 12 as 1 :+ 2 instead of () :+ 1 :+ 2. But I think, the latter representation should probably be prefered. (...) How 'bout treating :+ as similar to `append' rather than

  1   2   3   >