Re: [Haskell-cafe] mtl: Why there is Monoid w constraint in the definition of class MonadWriter?

2012-12-08 Thread Holger Siegel
Am 08.12.2012 um 23:18 schrieb Edward Z. Yang: Excerpts from Roman Cheplyaka's message of Sat Dec 08 14:00:52 -0800 2012: * Edward Z. Yang ezy...@mit.edu [2012-12-08 11:19:01-0800] The monoid instance is necessary to ensure adherence to the monad laws. This doesn't make any sense to me.

Re: [Haskell-cafe] mtl: Why there is Monoid w constraint in the definition of class MonadWriter?

2012-12-08 Thread Holger Siegel
Am 09.12.2012 um 00:27 schrieb Holger Siegel: For deriving a monoid instance of w from monad (Writer w), you will need function execWriter:: Writer w a - w, but in case of a general instance of (MonadWriter w m) you would have to use function listen :: m a - m (a, w) that will only provide

Re: [Haskell-cafe] Haskell integration with C/C++ (GSOC)

2012-04-05 Thread Holger Siegel
Am 05.04.2012 um 08:42 schrieb Brandon Allbery: On Thu, Apr 5, 2012 at 01:53, Sutherland, Julian julian.sutherlan...@imperial.ac.uk wrote: data Tree = Node Left Right | Leaf Could be converted to a struct in C/C++: struct Tree { struct Tree* left; struct Tree* right; };

Re: [Haskell-cafe] Inecxact map?

2012-03-13 Thread Holger Siegel
Am 13.03.2012 um 09:15 schrieb Morten Olsen Lysgaard: I'm running a project where i want to generate a map of a rather large data collection. The map is if the form: Data.Map.Map String a I'd like to be able to do inexact lookups on the map. Firstly, ignore the difference between upper

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Holger Siegel
Am 28.02.2012 um 18:06 schrieb Johan Holmquist: Two functions that I see useful are described here and I would like to know if they are defined in some more or less standard Haskell library. Hoogle (http://www.haskell.org/hoogle) did not reveal anything about that. Function 'inter'

Re: [Haskell-cafe] Does somebody know about these functions?

2012-02-28 Thread Holger Siegel
Am 28.02.2012 um 20:21 schrieb Johan Holmquist: inter :: (a - a - b) - [a] - [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l) This is the same as inter :: (a - a - b) - [a] - [b] inter f l = zipWith f l (tail l) Except when l == [], but the second equation can be

Re: [Haskell-cafe] types and number of evaluation steps

2012-02-18 Thread Holger Siegel
Am 18.02.2012 um 11:56 schrieb Heinrich Hördegen: Hi, this is true. The optimization only works with -O2. I'd like to have more details about what's going on. How can I make sure, that this optimization triggers? You cannot. Common subexpression elimination is done by GHC very

Re: [Haskell-cafe] types and number of evaluation steps

2012-02-18 Thread Holger Siegel
Am 18.02.2012 um 14:38 schrieb Roman Cheplyaka: * Holger Siegel holgersiege...@yahoo.de [2012-02-18 12:52:08+0100] You cannot. Common subexpression elimination is done by GHC very conservatively, because it can not only affect impure programs: it can also affects strictness/lazyness

Re: [Haskell-cafe] Not an isomorphism, but what to call it?

2012-01-19 Thread Holger Siegel
Am 19.01.2012 um 22:24 schrieb Sean Leather: I have two types A and B, and I want to express that the composition of two functions f :: B - A and g :: A - B gives me the identity idA = f . g :: A - A. I don't need g . f :: B - B to be the identity on B, so I want a weaker statement than

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Holger Siegel
Am 08.12.2011 um 11:13 schrieb Asger Feldthaus: Haskell doesn't seem to support disjunctive patterns, and I'm having a difficult time writing good Haskell code in situations that would otherwise call for that type of pattern. In Haskell I can't find any equivalent to the disjunctive

Re: [Haskell-cafe] minor refactoring problem

2011-11-29 Thread Holger Siegel
Am 29.11.2011 um 09:16 schrieb Martin DeMello: I have the following functions: makePair :: (String, String) - IO PairBox parseFile :: String - [(String, String)] importFile :: Editor - String - IO () importFile ed path = do s - readFile path ps - mapM (\x - makePair (x, )) (lines

Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Holger Siegel
Am 29.06.2011 um 23:50 schrieb Philipp Schneider: Hi cafe, in my program i use a monad of the following type newtype M a = M (State - (a, State)) i use the monad in two different ways. The type variable a can be a pair as in interp :: Term - Environment - M (Value,Environment)

Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Holger Siegel
Am 30.06.2011 um 20:23 schrieb Philipp Schneider: On 06/30/2011 02:36 PM, Holger Siegel wrote: Am 29.06.2011 um 23:50 schrieb Philipp Schneider: Hi cafe, in my program i use a monad of the following type newtype M a = M (State - (a, State)) i use the monad in two different ways

Re: [Haskell-cafe] overloading show function

2011-06-30 Thread Holger Siegel
Am 30.06.2011 um 22:57 schrieb Philipp Schneider: On 06/30/2011 09:49 PM, Holger Siegel wrote: (...) But that won't work: After you have evaluated an entry of the environment, you store the resulting value but you throw away its updated environment. That means, you lose the results of all

Re: [Haskell-cafe] Please add a method for optimized concat to the Semigroup class

2011-05-03 Thread Holger Siegel
Am 03.05.2011 um 13:39 schrieb Stephen Tetley: Does it have an obvious default implementation, bearing in mind it we might really want a total function? sconcat [] = error Yikes - I wish this was total! sconcat [a]= a sconcat (a:as) = a sconcat as You have to provide the neutral

Re: [Haskell-cafe] monadic plumbing

2011-02-22 Thread Holger Siegel
Am 22.02.2011 um 22:03 schrieb Alberto G. Corona: Recently I had to navigatate trough data structures chained with mutable referenes in th STM monad. The problem is that their values are enveloped in Either or Maybe results. functional compositions in the Either of Maybe , or list

Re: [Haskell-cafe] Tree Construction

2010-09-25 Thread Holger Siegel
Am 25.09.2010 um 11:54 schrieb Tom Hawkins: Hi, Often I need to assemble a tree from things with unstructured hierarchical paths. I built a function [1] to do this for ImProve. But does a library already exist that does this? If not I may create one, as I need it for a few different

Re: [Haskell-cafe] Shared thunk optimization. Looking to solidify my understanding

2010-09-22 Thread Holger Siegel
Am 22.09.2010 um 17:10 schrieb David Sankel: The following code (full code available here[1], example taken from comments here[2]), const' = \a _ - a test1 c = let a = const' (nthPrime 10) in (a c, a c) test2 c = let a = \_ - (nthPrime 10) in (a c, a c)

Re: [Haskell-cafe] Getting started

2010-07-01 Thread Holger Siegel
Am 01.07.2010 um 21:56 schrieb Mrwibbly: I'm having real trouble starting this project. Basically I have to create a record store that store information about artists and albums and also the number of sales that they have had. It also needs to generate a list of the top 5 sellers. So

Re: [Haskell-cafe] Different choice operations in a continuation monad

2010-06-15 Thread Holger Siegel
Hi Sebastian, Am 15.06.2010 um 17:06 schrieb Sebastian Fischer: Dear Café, `MonadPlus` instances are usually required to satisfy certain laws, among them the monad laws and monoid laws for `mzero` and `mplus`. Additionally one may require that (=f) is a monoid morphism, that is:

Re: [Haskell-cafe] Retrospective type-class extension

2010-05-20 Thread Holger Siegel
Am 20.05.2010 um 14:16 schrieb Tony Morris: I've compared and clearly the former is significantly superior :) I'm rather interested if there are any sound suggestions to resolve the general issue of retrospective type-class extension. I would like to have something like parent class

Re: [Haskell-cafe] GHC Install button grayed out

2010-05-17 Thread Holger Siegel
Am 18.05.2010 um 00:24 schrieb David Matuszek: I'm trying to install Haskell Platform 2010.1.0.1 on my Mac, downloaded from http://hackage.haskell.org/platform/ I have: Mac OS X 10.6.3 2 x 2.66 GHz Dual-Core Intel Xeon XCode 3.1.3 Also, I am an admin on this machine. When I try to

Re: [Haskell-cafe] A small oversight

2010-02-20 Thread Holger Siegel
Am Samstag, den 20.02.2010, 10:47 + schrieb Andrew Coppin: I just discovered the highly useful function Data.Function.on. I vaguely recall a few people muttering a couple of years back that this would be a useful thing to have, but I had no idea it was in the standard libraries now.

Re: [Haskell-cafe] Using ShowS or Difference Lists

2010-02-07 Thread Holger Siegel
Am Samstag, den 06.02.2010, 10:28 -0800 schrieb Ryan Ingram: As other people have mentioned, you are duplicating library functionality. But nobody has actually talked about the performance characteristics of your code. Fortunately for you, the calls to (++) in your recursion are

Re: [Haskell-cafe] Using ShowS or Difference Lists

2010-02-06 Thread Holger Siegel
Am Samstag, den 06.02.2010, 23:12 +1030 schrieb Mark Spezzano: Hi, Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code? It's basic text processing. It takes in a list of Lines where each Line is a list of Words and intersperses between

Re: [Haskell-cafe] Re: Very imperfect hash function

2010-02-01 Thread Holger Siegel
Am Donnerstag, den 28.01.2010, 19:37 + schrieb Maciej Piechotka: On Thu, 2010-01-28 at 14:07 -0500, Steve Schafer wrote: I'm looking for some algorithmic suggestions: I have a set of several hundred key/value pairs. The keys are 32-bit integers, and are all distinct. The values are

Re: [Haskell-cafe] Determining application directory

2010-01-27 Thread Holger Siegel
Am Mittwoch, den 27.01.2010, 21:19 +0300 schrieb Vladimir Matveev: Oh yeah, it seems I found it. Solution is to use getModuleFileName and getModuleHandle functions from System.Win32.DLL. Thanks for attention :) You can also use the (portable) package 'directory' from Hackage

Re: [Haskell-cafe] Rebox Package or To Hackage or not to Hackage

2009-12-08 Thread Holger Siegel
Am Dienstag, den 08.12.2009, 23:25 +0200 schrieb Vitaliy Akimov: Hi John, I don't know if this is useful for you, but these are instances of Cofunctor's comap. For example if we use TypeCompose package we have: rebox f = unFlip . cofmap f . Flip The rest are also Cofunctors. There are a

Re: [Fwd: Re: [Haskell-cafe] Implicit newtype unwrapping]

2009-12-03 Thread Holger Siegel
, 1] ? Should it unwrap the lists beforehand and re-wrap them afterwards and return Dual [1, 2] ? Should it unwrap the resulting list afterwards and return [1, 2] or even [2,1] ? That's not obvious to me. On Dec 3, 2009, at 1:25 AM, Holger Siegel wrote: Am Donnerstag, den 03.12.2009, 01

Re: [Haskell-cafe] Optimization with Strings ?

2009-12-03 Thread Holger Siegel
Am Donnerstag, den 03.12.2009, 16:23 +0100 schrieb Emmanuel CHANTREAU: Le Thu, 3 Dec 2009 13:20:31 +0100, David Virebayre dav.vire+hask...@gmail.com a écrit : It doesn't work this way : Strings are just lists of Chars. Comparison is made recursively, Char by Char. You can have a look at

[Fwd: Re: [Haskell-cafe] Implicit newtype unwrapping]

2009-12-02 Thread Holger Siegel
Am Donnerstag, den 03.12.2009, 01:16 +0100 schrieb Martijn van Steenbergen: So here's a totally wild idea Sjoerd and I came up with. What if newtypes were unwrapped implicitly? What advantages and disadvantages would it have? In what cases would this lead to ambiguous code? 1) instance

Re: [Haskell-cafe] Hopefully simple monad question

2009-09-16 Thread Holger Siegel
Am Mittwoch, den 16.09.2009, 03:23 -0700 schrieb Gregory Propf: I'm playing around with a little program that implements a simple virtual machine. I want to use a monad to represent machine state. I created a data type for the machine (VM) and a monadic type for the monadic computations

Re: [Haskell-cafe] least fixed points above something

2009-03-23 Thread Holger Siegel
Am Montag, den 23.03.2009, 12:55 + schrieb Jens Blanck: The above approach does not apply to my case. What I have is a monotone function f on a partial order satisfying f x = x, for all x. Given that the partial order is in fact a cpo this is enough to guarantee that a least fixed point

Re: [Haskell-cafe] Translating an imperative algorithm - negascout

2009-02-27 Thread Holger Siegel
Am Donnerstag, den 26.02.2009, 20:54 + schrieb Colin Paul Adams: Hello Haskellers, I want to implement the negascout algorithm for the game I'm writing. Wikipedia gives the algorithm in imperative terms: http://en.wikipedia.org/wiki/Negascout I've tried to translate this into

Re: [Haskell-cafe] Factoring into type classes

2009-01-19 Thread Holger Siegel
Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer: Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter: 2009/1/19 Luke Palmer lrpal...@gmail.com: As a side curiosity, I would love to see an example of any data structure which has more than one Functor instance. Especially

Re: [Haskell-cafe] Propositional logic implementation

2009-01-10 Thread Holger Siegel
On Sunday 11 January 2009 01:44:50 Andrew Wagner wrote: Nice Idea, though I don't know that I want something that extensive. I was more looking for whether there was a better way I could define the algebraic data type. Let's have a look at your definitions from http://hpaste.org/13807#a1 :

Re: [Haskell-cafe] Detecting system endianness

2008-12-18 Thread Holger Siegel
On Thursday 18 December 2008 13:40:47 Ryan Ingram wrote: Actually, this is probably safer: import Foreign.Marshal.Alloc import Foreign.Ptr import Foreign.Storable import Data.Word import System.IO.Unsafe endianCheck = unsafePerformIO $ alloca $ \p - poke p (0x01020304 :: Word32) peek

Re: [Haskell-cafe] Data.Map.fromListWith

2008-12-07 Thread Holger Siegel
On Saturday 06 December 2008 22:07:51 Paul Johnson wrote: So we could have fromListWithZero :: Ord k = (a - b - b) - b - [(k, a)] - Map k b fromListWithZero combiner zero pairs = ... The first time a key is seen the combining function is called with zero as its second argument. E.g.

Re: [Haskell-cafe] (OT) Humorous definition for fixed points?

2008-10-16 Thread Holger Siegel
On Thursday 16 October 2008 02:01:57 Corey O'Connor wrote: I was just reminded of one of the joke definitions of recursion: recursion: see recursion. Perhaps there is a similar one for fixed points? To learn about fixed points find the fixed point of the process: Given somebody learn about

Re: [Haskell-cafe] [ANN] Haskell Cheatsheet v1.0

2008-10-11 Thread Holger Siegel
On Saturday 11 October 2008 01:08:15 Justin Bailey wrote: This is a beta release (which is why I've limited the audience by using hackage) to get feedback before distributing the PDF to a wider audience. With that in mind, I welcome your comments or patches[2]. Justin [1]

AW: [Haskell-cafe] Fixed-Point Combinators

2008-07-16 Thread Holger Siegel
--- Adrian Neumann [EMAIL PROTECTED] schrieb am Mi, 16.7.2008: Von: Adrian Neumann [EMAIL PROTECTED] Betreff: [Haskell-cafe] Fixed-Point Combinators An: Haskell Cafe mailing list haskell-cafe@haskell.org Datum: Mittwoch, 16. Juli 2008, 21:17 Hello, while studying for a exam I came across