Re: [Haskell-cafe] Readable GHC 7.6.3 docs (Bootstrapped)

2013-09-11 Thread Twan van Laarhoven
Why does every section have a title=1.2.3 foo on the outer div? In Firefox this shows up as a useless tooltip when moving the mouse over the text. On 11/09/13 13:31, Obscaenvs wrote: At [1] you can find links to the GHC documentation that I use myself, since the official version is a bit too

Re: [Haskell-cafe] Alternative name for return

2013-08-14 Thread Twan van Laarhoven
On 13/08/13 17:38, Andreas Abel wrote: Indeed, I wished the 0-ary case would be more alike to the unary and binary case, cf. return f0 f1 $ a1 f2 $ a1 * a2 You could always write the above as pure f0 pure f1 * a1 pure f2 * a1 * a2 Twan

Re: [Haskell-cafe] Is the following implemented by a sparse matrix representation? type Graph n w = Array (n, n) (Maybe w)

2013-07-10 Thread Twan van Laarhoven
The standard array types, such as Array (n,n) (Maybe w) will be implemented as a dense array. If you want to use a sparse matrix, you will explicitly have to ask for it. For instance by using something like IntMap (IntMap w) or Map (n,n) w or Array n (IntMap w). Each of these representations is

Re: [Haskell-cafe] RFC: rewrite-with-location proposal

2013-02-25 Thread Twan van Laarhoven
On 25/02/13 07:06, Michael Snoyman wrote: Quite a while back, Simon Hengel and I put together a proposal[1] for a new feature in GHC. The basic idea is pretty simple: provide a new pragma that could be used like so: error :: String - a errorLoc :: IO Location - String - a {-#

Re: [Haskell-cafe] RFC: rewrite-with-location proposal

2013-02-25 Thread Twan van Laarhoven
On 25/02/13 13:41, Michael Snoyman wrote: At that point, we've now made two changes to REWRITE rules: 1. They can takes a new ALWAYS parameters. 2. There's a new, special identifier currentLocation available. What would be the advantage is of that approach versus introducing a single new

Re: [Haskell-cafe] Maintaining lambdabot

2013-02-20 Thread Twan van Laarhoven
On 20/02/13 08:13, Jan Stolarek wrote: Dnia wtorek, 19 lutego 2013, Gwern Branwen napisał: On Tue, Feb 19, 2013 at 5:36 PM, Jan Stolarek jan.stola...@p.lodz.pl wrote: - remove unlambda, brainfuck and show from the repo. They are on hackage, no need to keep them here - these packages aren't

Re: [Haskell-cafe] Subject: ANNOUNCE: grid-3.0.1 (tile maps for board games or maths)

2013-02-18 Thread Twan van Laarhoven
On 18/02/13 13:41, Amy de Buitléir wrote: I'm happy to announce a new major release of the grid package: http://hackage.haskell.org/package/grid https://github.com/mhwombat/grid/wiki (wiki) After taking a peek at the documentation: have you considered removing the size function

Re: [Haskell-cafe] Ticking time bomb

2013-01-31 Thread Twan van Laarhoven
On 31/01/13 09:16, Ketil Malde wrote: *MY* proposal is that: 0. Hackage sends an email to the previous uploader whenever a new version of a package is uploaded by somebody else. At least that way, I would be notified if it happened to my packages, and I would be able to check up on the

Re: [Haskell-cafe] Sparse records/ADTs

2012-10-24 Thread Twan van Laarhoven
On 24/10/12 12:08, Jon Fairbairn wrote: Is there a convenient way of handling a data structure with lots of fields of different types that may or may not be filled in? Not sure about convenience, but here is a type safe solution with O(log n) lookups and updates. The idea is to define a

Re: [Haskell-cafe] Platform Versioning Policy: upper bounds are not our friends

2012-08-16 Thread Twan van Laarhoven
On 16/08/12 14:07, Chris Smith wrote: As a package author, when I release a new version, I know perfectly well what incompatible changes I have made to it... and those might include, for example: 1. New modules, exports or instances... low risk 2. Changes to less frequently used, advanced, or

Re: [Haskell-cafe] Improvement suggestions

2012-08-15 Thread Twan van Laarhoven
On 15/08/12 17:01, José Lopes wrote: someFn docs = return concat `ap` (sequence $ intersperse (return \n) (map loop docs)) First of all, return x `ap` y = x `fmap` y or x $ y. fmap (or its infix synonym ($)) is the answer here, you could write: someFn docs = concat . intersperse \n $

Re: [Haskell-cafe] Fixity declaration extension

2012-08-14 Thread Twan van Laarhoven
On 14/08/12 13:46, Ketil Malde wrote: AntC anthony_clay...@clear.net.nz writes: I agree. I don't declare operators very often, and when I do I always struggle to remember which way round the precedence numbers go. [...] (Anything else we can bikeshed about while we're at it?) infixl

Re: [Haskell-cafe] Applicative functors with branch/choice ?

2012-07-26 Thread Twan van Laarhoven
On 26/07/12 12:40, Евгений Пермяков wrote: class Applicative f = Actuative f where -- | select computation conditionally . Side effects of only one two alternative take place select :: f (Either a b) -- ^ selector - f (a - c) -- ^ first alternative -

Re: [Haskell-cafe] Applicative functors with branch/choice ?

2012-07-26 Thread Twan van Laarhoven
On 26/07/12 13:58, Евгений Пермяков wrote: As you can see, if I use select definition with Control.Applicative.*, I'll execute both l and r and the only choice will be, what result to drop. Both l and r, however, will be executed, and their side effects will take place. With select from my code

Re: [Haskell-cafe] Applicative functors with branch/choice ?

2012-07-25 Thread Twan van Laarhoven
On 2012-07-25 22:22, Евгений Пермяков wrote: Let assume, that some computation takes argument and produces value Either a b. This computation may be represented in for different forms computePure :: a - Either b c computeMonad :: a - m (Either b c) computeApplicative :: app a - app

Re: [Haskell-cafe] Is (==) commutative?

2012-07-24 Thread Twan van Laarhoven
On 2012-07-24 10:10, Christian Sternagel wrote: Dear all, with respect to formal verification of Haskell code I was wondering whether (==) of the Eq class is intended to be commutative (for many classes such requirements are informally stated in their description, since Eq does not have such a

Re: [Haskell-cafe] Is (==) commutative?

2012-07-24 Thread Twan van Laarhoven
On 24/07/12 13:32, Frank Recker wrote: I agree, that (==) should be symmetric. However, it is easy to write Eq-instance, which violates this law: It is impossible to specify laws such as symmetry in Haskell, which is why they are usually stated in the documentation. However, this style of

Re: [Haskell-cafe] Is (==) commutative?

2012-07-24 Thread Twan van Laarhoven
On 24/07/12 14:39, Jonas Almström Duregård wrote: Hi, I suppose you need to define what commutativity means in the presence of undefined values. For instance if error 0 is different from error 1 then you do not have commutativity. Also nontermination needs to be considered, for instance (fix $

Re: [Haskell-cafe] Is (==) commutative?

2012-07-24 Thread Twan van Laarhoven
On 24/07/12 14:44, timothyho...@seznam.cz wrote: There's always this, for ALL types a :( So even where you would think that the documentation can claim that a given Eq instance follows the law of commutativity, it really cannot. Once you invoke unsafePerformIO, you can break the type system,

Re: [Haskell-cafe] arbitrary rank polymorphism and ghc language pragmas

2012-07-05 Thread Twan van Laarhoven
On 05/07/12 17:18, rickmurphy wrote: Hi All: I've been working through some details in these papers [1], [2] and noticed a language pragma configuration that I hope you can confirm. When using explicit foralls in a data constructor, it appears that GHC 7.4.2 requires Rank2Types in the Language

Re: [Haskell-cafe] Fundeps and overlapping instances

2012-05-24 Thread Twan van Laarhoven
On 24/05/12 14:14, AntC wrote: Simon Peyton-Jonessimonpjat microsoft.com writes: [from 7 Jul 2010. I've woken up this thread at Oleg's instigation http://www.haskell.org/pipermail/haskell-prime/2011-July/003491.html ] I'm not going to talk about Fundeps. This is about introducing

Re: [Haskell-cafe] Problem with forall type in type declaration

2012-05-11 Thread Twan van Laarhoven
On 04/05/12 09:08, Magicloud Magiclouds wrote: Hi, Assuming this: run :: Monad IO a - IO a data Test = Test { f } Here I'd like to set f to run, like Test run. Then what is the type of f? The confusing (me) part is that, the argument pass to f is not fixed on return type, like f1 ::

Re: [Haskell-cafe] Reconstructing a tree from a list of its paths (to leaves)

2012-04-10 Thread Twan van Laarhoven
On 10/04/12 09:55, Arnaud Bailly wrote: Hello, I am manipulating labeled multiway trees, some kind of lightweight XML notation. One thing I would like to be able to do is manipulating a tree as a list of (Path, Value). Generating such a list is easy but I am a little bit surprised to find it

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.1.0

2012-04-10 Thread Twan van Laarhoven
On 09/04/12 23:49, Paolo Capriotti wrote: I'm pleased to announce the release of version 0.1.0 of pipes-core, a library for efficient, safe and compositional IO, similar in scope to iteratee and conduits. http://hackage.haskell.org/package/pipes-core I have some issues with the function

Re: [Haskell-cafe] Mixing Unboxed Mutable Vectors and Parsers

2012-04-10 Thread Twan van Laarhoven
On 2012-04-07 23:35, Myles C. Maxfield wrote: CC: Maintainers of STMonadTrans, Vector, and JuicyPixels Hello, I am writing a Haskell Attoparsec parser which will modify 2-d arrays of small values (Word8, Int8, etc.). My first idea was to simply parse all the deltas, and later apply them to the

Re: [Haskell-cafe] is the evaluation order deterministic when using applicative with IO

2012-03-16 Thread Twan van Laarhoven
On 16/03/12 10:45, Rouan van Dalen wrote: Hi everyone. I was wondering if I can make assumptions about the evaluation order of the following code: isTrue :: Int - IO Bool isTrue val = pure (||) * boolTest1 val * boolTest2 val {- boolTest1 is an inexpensive, quick check -} boolTest1 :: Int -

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Twan van Laarhoven
On 11/03/12 23:41, Chris Smith wrote: On Sun, Mar 11, 2012 at 2:33 PM, Twan van Laarhoventwa...@gmail.com wrote: I think you should instead move unwaits in and out of the composition on the left side: unawait x (p1+ p2) === (unawait x p1)+ p2 This makes idP a left-identity for (+),

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-11 Thread Twan van Laarhoven
On 2012-03-11 14:09, Paolo Capriotti wrote: The Category law would be broken, though: unawait x id == yield x !== unawait x How did you get this equation? It's not even well-typed: unawait :: a - Pipe a b m () yield :: b - Pipe a b m () I would expect that (id unawait x) await

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-11 Thread Twan van Laarhoven
On 2012-03-11 14:46, Paolo Capriotti wrote: On Sun, Mar 11, 2012 at 1:25 PM, Twan van Laarhoventwa...@gmail.com wrote: I would expect that (id unawait x) await !== unawait x await === return x There are several type errors in this equation, so I'm not exactly sure what you mean.

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-11 Thread Twan van Laarhoven
On 2012-03-11 17:30, Mario Blažević wrote: It's difficult to say without having the implementation of both unawait and all the combinators in one package. I'll assume the following equations hold: unawait x await = return x unawait x yield y = yield y unawait x (p1 unawait x) p2 = (p1 p2)

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-10 Thread Twan van Laarhoven
On 2012-03-10 11:16, Paolo Capriotti wrote: Another issue is how to deal with unconsumed input. For that, there is a ChunkPipe type (in pipes-extra) with a specialized monad instance that threads unconsumed input along. You can see an example of ChunkPipe in action in this prototype http server

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-10 Thread Twan van Laarhoven
On 2012-03-11 00:09, Mario Blažević wrote: On 12-03-10 05:19 PM, Twan van Laarhoven wrote: -- | Pass some unconsumed input back upstream. -- The next @await@ will return this input without blocking. unawait :: Monad m = a - Pipe a b m () The function may be called unawait, but there's nothing

Re: [Haskell-cafe] Finding longest common prefixes in a list

2012-01-21 Thread Twan van Laarhoven
On 2012-01-20 23:44, Gwern Branwen wrote: On Fri, Jan 20, 2012 at 1:57 PM, Twan van Laarhoventwa...@gmail.com wrote: Here is some example code (untested): Well, you're right that it doesn't work. I tried to fix the crucial function, 'atLeastThisManyDescendants', but it's missing something

Re: [Haskell-cafe] Right tree structure for complicated problem

2012-01-21 Thread Twan van Laarhoven
On 2012-01-22 00:39, Pierre Penninckx wrote: So here is what I want to achieve: I'd like a program that calculates the time needed for water to flow out of a circuit made out of tube. The rules are : - There are multiple sources of water and only one exit. - The water can only take one path from

Re: [Haskell-cafe] instance (Enum a) = IArray UArray a

2012-01-20 Thread Twan van Laarhoven
On 20/01/12 16:31, Mikhail Arefiev wrote: Is there a reason why there is no instance of (Enum a) = IArray UArray a (other than that it will require OverlappingInstances and/or IncoherentInstances if e. g. UArray of Bools is used in the same code)? ... Does having such thing make any

Re: [Haskell-cafe] Finding longest common prefixes in a list

2012-01-20 Thread Twan van Laarhoven
On 20/01/12 18:45, Gwern Branwen wrote: Recently I wanted to sort through a large folder of varied files and figure out what is a 'natural' folder to split out, where natural means something like4 files with the same prefix. My idea for an algorithm would be: build a trie for the input

Re: [Haskell-cafe] Current Haskell report URL

2011-11-25 Thread Twan van Laarhoven
On 23/11/11 23:02, Tom Murphy wrote: Is there a reason that the Haskell 2010 report is in a subdirectory of haskell.org/onlinereport http://haskell.org/onlinereport (which currently points to the Haskell98 standard)? http://www.haskell.org/onlinereport/ -- Haskell98

Re: [Haskell-cafe] Documenting strictness properties for Data.Map.Strict

2011-11-18 Thread Twan van Laarhoven
On 18/11/11 06:44, Johan Tibell wrote: On Thu, Nov 17, 2011 at 9:21 PM, Johan Tibelljohan.tib...@gmail.com wrote: I'm not entirely happy with this formulation. I'm looking for something that's clear (i.e. precise and concise, without leaving out important information), assuming that the reader

Re: [Haskell-cafe] Superset of Haddock and Markdown

2011-11-18 Thread Twan van Laarhoven
On 18/11/11 09:18, Ivan Lazar Miljenovic wrote: On 18 November 2011 19:06, Roman Cheplyakar...@ro-che.info wrote: Maybe have a switch that enables markdown and disables markup-related features of haddock (everything except linking to identifiers/modules, I believe), so that we don't affect

Re: [Haskell-cafe] How to speedup generically parsing sum types?

2011-11-03 Thread Twan van Laarhoven
On 03/11/11 11:16, Bas van Dijk wrote: ... instance (Constructor c, GFromJSON a, ConsFromJSON a) = GFromSum (C1 c a) where gParseSum (key, value) | key == pack (conName (undefined :: t c a p)) = gParseJSON value | otherwise = notFound $ unpack key {-#

Re: [Haskell-cafe] Attoparsec: Limiting Parsers to N Bytes, or Combing Parsers?

2011-09-26 Thread Twan van Laarhoven
On 24/09/11 05:21, Evan Laforge wrote: hex2 = (+)$ ((*16)$ higit)* higit higit = subtract (fromEnum '0')$ satisfy isHexDigit color = Color$ hex2* hex2* hex2 How is subtract (fromEnum '0') supposed to convert a hex digit to an Int or Word8? I think you need digitToInt (or an equivalent

Re: [Haskell-cafe] ghc 7.0.3 view patterns and exhaustiveness

2011-09-21 Thread Twan van Laarhoven
On 2011-09-21 22:06, Brent Yorgey wrote: On Tue, Sep 20, 2011 at 10:31:58PM -0400, Richard Cobbe wrote: numVarRefs :: Term - Integer numVarRefs (view - Var _) = 1 numVarRefs (view - App rator rand) = numVarRefs rator + numVarRefs rand numVarRefs (view - Lam _ body) =

Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Twan van Laarhoven
On 2011-06-27 13:51, Steffen Schuldenzucker wrote: Could you specify what exactly the function is supposed to do? I am pretty sure that a function like seqPeriod :: (Eq a) = [a] - Maybe Integer -- Nothing iff non-periodic cannot be written. What about sequences that can be specified in terms

Re: [Haskell-cafe] Links into list

2011-05-02 Thread Twan van Laarhoven
On 02/05/11 13:10, John Sneer wrote: Simply: I would like to have direct access into several places in a very long list. Maybe you could use a zipper. Or just maintain the list split into chunks. So l' = [stuffBefore,hi,stuffAfter]. Or if you want to be able to use each element of hi as a

Re: [Haskell-cafe] Testing Implementation vs Model - Records or Type Classes?

2011-04-08 Thread Twan van Laarhoven
On 08/04/11 11:54, Heinrich Apfelmus wrote: Hello, I'm writing a small Haskell library for functional reactive programming. The core of the library consists of two data types and several primitives. However, I have programmed this core *twice*: once as a *model* that displays the intended

Re: [Haskell-cafe] The mother of all functors/monads/categories

2010-06-27 Thread Twan van Laarhoven
Max Bolingbroke wrote: I don't actually know what the right name for this data type is, I just invented it and it seems to work: -- () :: forall a b. t a b - (forall c. t b c - t a c) newtype Wotsit t a b = Wotsit { runWotsit :: forall c. t b c - t a c } There is of course no reason to

Re: [Haskell-cafe] Is there good place to post Haskell alorithms/data structures that follow Steven Skiena's book on algorithm design and also Haskell code snippets that follow some of Knuth's books?

2010-06-21 Thread Twan van Laarhoven
Casey Hawthorne wrote: Is there good place to post Haskell alorithms/data structures that follow Steven Skiena's book on algorithm design and also Haskell code snippets that follow some of Knuth's books? These code snippets don't seem to fit with Hackage. You could make some pages for them on

Re: [Haskell-cafe] The 8 Most Important GSoC Projects

2010-04-02 Thread Twan van Laarhoven
Ivan Lazar Miljenovic wrote: I've been thinking of doing something similar for a year or so now, but there's one big problem that I can think of: how to deal with functions that don't have an explicit type signature in the source. My understanding is that to derive these signatures at checking

Re: [Haskell-cafe] Haskell.org re-design

2010-04-01 Thread Twan van Laarhoven
Christopher Done wrote: That's true, it's a nice idea but in practice it's hard to know where to focus. I've gone with a left nav. I've built up the HTML which is cross-browser (ie6/7/8/opera/firefox/safari/chrome compat), still need to add some bits but I can tomorrow import it into a wikimedia

Re: [Haskell-cafe] Asynchronous exception wormholes kill modularity

2010-03-25 Thread Twan van Laarhoven
Bas van Dijk wrote: ... However now comes the problem I would like to talk about. What if I want to use modifyMVar_ as part of a bigger atomic transaction. As in: block $ do ... modifyMVar_ m f ... From a quick glanse at this code it looks like asynchronous exceptions

Re: [Haskell-cafe] Map unionWith generalization

2010-01-27 Thread Twan van Laarhoven
Hans Aberg wrote: For example, in Map String Integer (sparse representation of monomials) compute the minimum value of all associative pairs with the same key (the gcd); if only one key is present, the absent should be treated as having value 0. So unionWith min xs ys will not work, because

Re: [Haskell-cafe] Capped lists and |append|

2010-01-08 Thread Twan van Laarhoven
John Millikin wrote: Earlier today I uploaded the capped-list package; I didn't think there would be any interest, since it's a relatively trivial data structure, but already there's been three emails and an IRC convo about it. Since uploading, there's been a big problem pointed out to me

Re: [Haskell-cafe] Re: Data.Ring -- Pre-announce

2009-12-31 Thread Twan van Laarhoven
John Van Enk wrote: Hi Heinrich, I think I like Ring more than Necklace or Tom's suggestion of Circular. I chose Ring simply because that's what I was searching for when I wanted the data structure. The package will be named data-ring, so that should hopefully be enough to clue in the user

Re: [Haskell-cafe] The Transient monad

2009-12-08 Thread Twan van Laarhoven
Alberto G. Corona wrote: Hi haskell cafe: concerning Stable Names The IO in makeStableName suggest more side effects than makeStableName really do. But still the call isn't pure. For calls such are makeStableName that gives a different result the FIRST time they are called but return the

Re: [Haskell-cafe] Applicative Functor or Idiom?

2009-11-20 Thread Twan van Laarhoven
David Sankel wrote: After reading several recent papers I came to the understanding that there isn't consensus on the name of Applicative Functors. Several prefer to call them idioms: 'Idiom' was the name McBride originally chose, but he and Paterson now favour the less evocative term

Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-19 Thread Twan van Laarhoven
Nicolas Pouillard wrote: The TDNR proposal really tries to do two separate things: 1. Record syntax for function application. The proposal is to tread x.f or a variation thereof the same as (f x) It is more like (ModuleToGuess.f x) than (f x). My point is that desugaring x.f to (f

Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-18 Thread Twan van Laarhoven
Levi Greenspan wrote: What's the status of the TDNR proposal [1]? Personally I think it is a very good idea and I'd like to see it in Haskell'/GHC rather sooner than later. Working around the limitations of the current record system is one of my biggest pain points in Haskell and TDNR would be a

Re: [Haskell-cafe] Fair diagonals

2009-11-04 Thread Twan van Laarhoven
Sjoerd Visscher wrote: I believe this does what you want: code The attached code should be more efficient, since it doesn't use integer indices. Note that this is just a 'level' monad: the list is stratified into levels, when combining two levels, the level of the result is the sum of the

Re: [Haskell-cafe] Proposal: TypeDirectedNameResolution

2009-08-13 Thread Twan van Laarhoven
John Meacham wrote: On Mon, Jul 27, 2009 at 04:41:37PM -0400, John Dorsey wrote: I'm assuming that name resolution is currently independent of type inference, and will happen before type inference. With the proposal this is no longer true, and in general some partial type inference will have

Re: [Haskell-cafe] Float instance of 'read'

2008-09-16 Thread Twan van Laarhoven
Mauricio wrote: Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that

Re: [Haskell-cafe] Monad vs ArrowChoice

2008-05-14 Thread Twan van Laarhoven
Ronald Guida wrote: I have read that Monad is stronger than Idiom because Monad lets me use the results of a computation to choose between the side effects of alternative future computations, while Idiom does not have this feature. Arrow does not have this feature either. ArrowChoice has the

Re: [Haskell-cafe] M1 + M2 = M3 where both computations in M1 and M2 can be used?

2008-05-12 Thread Twan van Laarhoven
sam lee wrote: Hi. I want to compose two monads to build another monad where computations of the two monads can be used inside. I have: - MonadTypeInfer : interface (class) for TypeInfer monad - TypeInfer : a monad that has Map String Type (association of names and types) - TypeInferT :

Re: [Haskell-cafe] A commutative diagram conjecture about applicative functors

2007-12-31 Thread Twan van Laarhoven
Isaac Dupree wrote: Unfortunately, I get puzzling type errors if I annotate either one of them with their type (e.g. (Applicative f) = f (a - b) - f a - f (Int, b) ) in an expression. The very answer doesn't seem to typecheck. :t \f x - fmap ((,) (0::Int)) (f * x) :: (Applicative f) = f (a1

Re: [Haskell-cafe] A commutative diagram conjecture about applicative functors

2007-12-30 Thread Twan van Laarhoven
Robin Green wrote: I am proving various statements relating to applicative functors, using the Coq proof assistant (I am considering only Coq terms, which always terminate so you don't have to worry about _|_). However, I'm not sure how to go about proving a certain conjecture, which,

Re: [Haskell-cafe] Is a type synonym declaration really a synonym ?

2007-12-22 Thread Twan van Laarhoven
alpheccar wrote: Can someone confirm me that: type TA = A :+: B type TB = C :+: D type T = TA :+: TB This is type T = (A :+: B) :+: (C :+: D) is not equivalent to type T = A :+: B :+: C :+: D is type T = A :+: (B :+: (C :+: D)) So these types are indeed not the same. Twan

Re: [Haskell-cafe] Smart Constructor Puzzle

2007-12-20 Thread Twan van Laarhoven
Ronald Guida wrote: I'm playing around with smart constructors, and I have encountered a weird puzzle. My goal is to do vector arithmetic. I'm using smart constructors so that I can store a vector as a list and use the type system to staticly enforce the length of a vector. So my first step

Re: [Haskell-cafe] list utilities -- shouldn't these be in the hierarchical libs somewhere?

2007-12-18 Thread Twan van Laarhoven
Jules Bean wrote: Thomas Hartman wrote: I found http://haskell.cs.yale.edu/haskell-report/List.html had many useful one off type list functions such as subsequences and permutations which are nowhere to be found in hoogle, Data.List, or the haskell hierarchical libs Weird. It's

Re: [Haskell-cafe] class default method proposal

2007-12-12 Thread Twan van Laarhoven
Simon Peyton-Jones wrote: Concerning (b) here's a suggestion. As now, require that every instance requires an instance declaration. So, in the main example of http://haskell.org/haskellwiki/Class_system_extension_proposal, for a new data type T you'd write instance Monad T where

Re: [Haskell-cafe] Showing Data.Ratio - different on GHC vs Hugs/Yhc

2007-11-16 Thread Twan van Laarhoven
Neil Mitchell wrote: Hi Under Hugs and Yhc, showing a Ratio 1%2 gives 1 % 2. Under GHC showing 1%2 gives 1%2. Does the standard say anything about this? Is someone wrong? Yes, ghc is wrong here, the Haskell 98 report [1] specifies: instance (Integral a) = Show (Ratio a) where

Re: [Haskell-cafe] Transformation sequence

2007-10-20 Thread Twan van Laarhoven
Andrew Coppin wrote: I'm writing some code where I take an expression tree and transform it into another equivilent one. Now it's moderately easy to write the code that does the transformation. But what I *really* want is to print out the transformation *sequence*. This appears to be much

Re: [Haskell-cafe] Re: PROPOSAL: New efficient Unicode string library.

2007-10-02 Thread Twan van Laarhoven
Lots of people wrote: I want a UTF-8 bikeshed! No, I want a UTF-16 bikeshed! What the heck does it matter what encoding the library uses internally? I expect the interface to be something like (from my own CompactString library): fromByteString :: Encoding - ByteString - UnicodeString

Re: [Haskell-cafe] PROPOSAL: New efficient Unicode string library.

2007-09-24 Thread Twan van Laarhoven
Johan Tibell wrote: Dear haskell-cafe, I would like to propose a new, ByteString like, Unicode string library which can be used where both efficiency (currently offered by ByteString) and i18n support (currently offered by vanilla Strings) are needed. I wrote a skeleton draft today but I'm a

Re: [Haskell-cafe] Accumulator value for and and or

2007-09-21 Thread Twan van Laarhoven
PR Stanley wrote: Hi or = foldl (||) False and = foldl () True I can understand the rationale for the accumulator value - True [] where [] = True and True || [] where [] = False Other than the practical convenience is there a reason for having the empty list in and and or equating to True and

Re: [Haskell-cafe] Extending the idea of a general Num to other types?

2007-09-05 Thread Twan van Laarhoven
Bulat Ziganshin wrote: Hello Simon, Wednesday, September 5, 2007, 11:19:28 AM, you wrote: when you come across a case where GHC produces an unhelpful message, send it in, along with the program that produced it, i have put such tickets about year ago :) basically, it

Re: [Haskell-cafe] GHC optimisations

2007-08-22 Thread Twan van Laarhoven
Stefan O'Rear wrote: On Wed, Aug 22, 2007 at 06:36:15PM +0100, Neil Mitchell wrote: Hi If Num obeys ring axioms, fromInteger is a perfectly fine ring-homomorphism. (It's also the first or second homomorphism taught.) Does Int obey these axioms? I'm thinking that assuming properties about

Re: [Haskell-cafe] GHC optimisations

2007-08-21 Thread Twan van Laarhoven
Isaac Dupree wrote: Simon Peyton-Jones wrote: ... No, constant folding is part of the compiler, I'm afraid, in the module PrelRules. Simon _Constant_ folding is, but in GHC.Base there are rules like (unboxed) multiplying by zero or one, or adding or subtracting zero, from an unknown

Re: [Haskell-cafe] GHC optimisations

2007-08-21 Thread Twan van Laarhoven
Brandon S. Allbery KF8NH wrote: On Aug 21, 2007, at 22:13 , Twan van Laarhoven wrote: Other rules that could be interesting are: forall a b. fromInteger a + fromInteger b = fromInteger (a + b) I don't think this will work, a and b have to be the same type. They are of the same type

Re: [Haskell-cafe] Chessboard-building in Haskell

2007-08-18 Thread Twan van Laarhoven
Andrew Wagner wrote: I've started a blog series on writing a chess engine in Haskell. I just posted the second blog entry today: http://sequence.complete.org/node/361 I suspect there's more work to be done on that function, though. It seems like there should be a nice way to remove that flip in

Re: [Haskell-cafe] How do I simulate dependent types using phantom types?

2007-08-18 Thread Twan van Laarhoven
DavidA wrote: Hi, I am trying to implement quadratic fields Q(sqrt d). These are numbers of the form a + b sqrt d, where a and b are rationals, and d is an integer. ... class IntegerType a where value :: Integer The problem is, this doesn't work. GHC complains: The class method

Re: [Haskell-cafe] Re: Re: Re: monad subexpressions

2007-08-03 Thread Twan van Laarhoven
Antoine Latter wrote: On 8/3/07, Chris Smith [EMAIL PROTECTED] wrote: Yes, unless of course you did: instance (Monad m, Num n) = Num (m n) or some such nonsense. :) I decided to take this as a dare - at first I thought it would be easy to declare (Monad m, Num n) = m n to be an

Re: [Haskell-cafe] Read-only functions in State Monad

2007-06-30 Thread Twan van Laarhoven
Ken Takusagawa wrote: I'd like to have a state monad with the feature that I can somehow annotate using the type system that some functions are only going to read the state and not modify it. Such read-only functions are only permitted to call other read-only functions, whereas state-modifying

Re: [Haskell-cafe] Disadvantages of de Bruijn indicies?

2007-05-11 Thread Twan van Laarhoven
Neil Mitchell wrote: Hi, de Bruijn indicies look quite nice, and seem to eliminate a lot of complexity when dealing with free variables: http://en.wikipedia.org/wiki/De_Bruijn_index So I was wondering, are they suitable for use in a compiler? If so, what are their disadvantages/advantages? Is

Re: [Haskell-cafe] Recent content is available under a simple permissive license

2007-05-11 Thread Twan van Laarhoven
Robin Green wrote: The Haskell wiki[1] says Recent content is available under a simple permissive license. But this is unilluminating - recent? how recent, exactly? - and will become increasingly understated as time goes by. Wouldn't it be slightly more helpful to say Content added after ...

Re: [Haskell-cafe] Morphing ASTs and scrapping boilerplate code

2007-04-19 Thread Twan van Laarhoven
Joel Reymont wrote: I have a lot of boilerplate code like this and wonder how I can scrape it. instance Morpher Type C.Type where morph TyInt = return C.TyInt morph TyFloat = return C.TyFloat morph TyStr = return C.TyStr morph TyBool = return C.TyBool morph TyColor = return

Re: [Haskell-cafe] Automatic derivation (TemplateHaskell?)

2007-04-05 Thread Twan van Laarhoven
Joel Reymont wrote: This is in Language.Haskell.TH.Syntax which is imported at the top of Data/Derive/TH.hs so I don't understand the cause of the error instance Functor Q where fmap f (Q x) = Q (fmap f x) ... Any suggestions? Since Q is a Monad, you can make the instance instance

Re: [Haskell-cafe] Duplicate instance declaration

2007-03-22 Thread Twan van Laarhoven
Bas van Dijk wrote: I would also like to get the formatting constraints working. However the solution in the code below gives a Duplicate instance declarations error. If I -fallow-overlapping-instances than the type checker goes into an infinite loop. I would like to know why this is

[Haskell-cafe] Consequences of newtype deriving implementation w.r.t. base classes

2007-03-13 Thread Twan van Laarhoven
and Read, because they cannot be derived in that way. It will, however, catch problems with most other classes. Twan van Laarhoven ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Implementation of scaled integers

2007-02-13 Thread Twan van Laarhoven
Stefan Heinzmann wrote: Hi all, is there a library for Haskell that implements scaled integers, i.e. integers with a fixed scale factor so that the scale factor does not need to be stored, but is part of the type? Data.Fixed [1] does exactly that, only it is based on Integer. Using fixed

Re: [Haskell-cafe] foreach

2006-09-18 Thread Twan van Laarhoven
Couldn't '\' delimit a subexpression, as parentheses do? Would there be any ambiguity in accepting code like State \s - (s, s) instead of requiring State $ \s - (s, s), or taking Looking at the Haskell 98 language definition it seems that a whole class of these expressions are disallowed

Re: [Haskell-cafe] MonadList?

2006-09-13 Thread Twan van Laarhoven
Michael Shulman wrote: The frequent occurence of ListT $ return in my code when I use the ListT monad transformer has made me wonder why there isn't a standard typeclass `MonadList', like those for the other monad transformers, encapsulating the essence of being a list-like monad -- in this

Re: [Haskell-cafe] Optimization problem

2006-09-13 Thread Twan van Laarhoven
Magnus Jonsson wrote: Dear Haskell Cafe, When programming the other day I ran into this problem. What I want to do is a function that would work like this: splitStreams::Ord a=[(a,b)]-[(a,[b])] splitStreams [(3,x),(1,y),(3,z),(2,w)] [(3,[x,z]),(1,[y]),(2,[w])] A O(n log(n)) algorithm

Re: [Haskell-cafe] Simple matrix

2006-06-21 Thread Twan van Laarhoven
Jared Updike wrote: Wouldn't you want the expression [[1,0],[0,2]] + 10 to yield [[11,10],[10,12]] You could handle this as a special case in (+) and (*), but this is kind of a hack. Something like: (+) [[x]] y = map (map (x+)) y (+) x [[y]] = map (map (+y)) x (+) xy =

Re: [Haskell-cafe] QuickChecking IO

2006-05-25 Thread Twan van Laarhoven
Mike Gunter wrote: I'd like to use QuickCheck on IO code. For instance, I'd like to check a property of type String - IO Bool. Using unsafePerformIO seems straightforward (though I haven't written the code, so I may be wrong about that) and it might be possible to make a solution involving

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread Twan van Laarhoven
SevenThunders wrote: test.hs:14:11: No instance for (PrintfType (t t1)) arising from use of `printf' at test.hs:14:11-16 Probable fix: add an instance declaration for (PrintfType (t t1)) In the result of a 'do' expression: printf %14.7g u In the definition of `test':

Re: [Haskell-cafe] Partial Derivatives

2006-05-08 Thread Twan van Laarhoven
Gerhard Navratil wrote: I need a library that provides partial derivatives for functions. The solution I came up with is based on a datatype using reversed polish notation to store the function: lots of code The solution works but is not very elegant. The complete module is appended to