Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 3:52:54 AM, you wrote: I fail to see how it will brake programs. Current programs do not use Unicode because it is implemented incorrectly. i use it. current Linux implementation treats String as sequence of bytes, and with manual recoding it allows to use

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Roman Beslik
On 27.06.10 04:07, Brandon S Allbery KF8NH wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/26/10 19:52 , Roman Beslik wrote: I fail to see how it will brake programs. Current programs do not use Unicode because it is implemented incorrectly. Currently, FilePath is an alias for

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Roman Beslik
On 27.06.10 03:58, Felipe Lessa wrote: On Sun, Jun 27, 2010 at 02:55:33AM +0300, Roman Beslik wrote: On 26.06.10 15:44, Felipe Lessa wrote: However, suppose your program needs to create a file with a name based on a database information. Your database is UTF-8. How do you translate that

Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 11:07:47 AM, you wrote: Currently, FilePath is an alias for String. Changing FilePath to a real type Just do not change FilePath, what may be simpler? if FilePath will become abstract type, it will break all programs that use it since they use it as

Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 11:11:59 AM, you wrote: No! The target encoding is the current locale. It is a no-brainer to not necessarily. current locale, encoding of current terminal and encoding of every filesystem mounted are all different things -- Best regards, Bulat

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Roman Beslik
On 27.06.10 09:38, Bulat Ziganshin wrote: Sunday, June 27, 2010, 3:52:54 AM, you wrote: I fail to see how it will brake programs. Current programs do not use Unicode because it is implemented incorrectly. i use it. current Linux implementation treats String as sequence of bytes, and with

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Roman Beslik
On 27.06.10 10:17, Bulat Ziganshin wrote: Sunday, June 27, 2010, 11:07:47 AM, you wrote: Currently, FilePath is an alias for String. Changing FilePath to a real type Just do not change FilePath, what may be simpler? if FilePath will become abstract type, it will break all programs that use

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Roman Beslik
On 27.06.10 10:18, Bulat Ziganshin wrote: Hello Roman, Sunday, June 27, 2010, 11:11:59 AM, you wrote: No! The target encoding is the current locale. It is a no-brainer to not necessarily. current locale, encoding of current terminal and encoding of every filesystem mounted are all different

Re: [Haskell-cafe] Construction of short vectors

2010-06-27 Thread Alexey Khudyakov
On Fri, 25 Jun 2010 18:30:06 -0300 Felipe Lessa felipe.le...@gmail.com wrote: On Fri, Jun 25, 2010 at 12:41:48AM +0400, Alexey Khudyakov wrote: Then constructor like one below arise naturally. And I don't know how to write them properly. It's possible to use fromList but then list could

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

2010-06-27 Thread Max Bolingbroke
I'm wondering if someone can cast some light on a pattern I've come across, which I'm calling the mother of all X pattern after Dan Piponi's blog post (http://blog.sigfpe.com/2008/12/mother-of-all-monads.html). Edward Kmett has also explored these ideas here:

Re: [Haskell-cafe] Construction of short vectors

2010-06-27 Thread Roman Leshchinskiy
On 25/06/2010, at 06:41, Alexey Khudyakov wrote: Then constructor like one below arise naturally. And I don't know how to write them properly. It's possible to use fromList but then list could be allocated which is obviously wasteful. vector2 :: Double - Double - Vec2D vector2 x y = ...

Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 11:24:16 AM, you wrote: O'kay, but IMHO few people want to have a headache with recoding. You knew that the implementation was incorrect, why you relied on it? what is alternative? :) on windows i've used low-level open()-styly APIs, on Linux i got the

Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 11:28:49 AM, you wrote: Just do not change FilePath, what may be simpler? if FilePath will become abstract type, it will break all programs that use it since they use it as String Hello, do you read me? I said: do not change FilePath. what you mean by

Re[2]: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Bulat Ziganshin
Hello Roman, Sunday, June 27, 2010, 11:37:24 AM, you wrote: No! The target encoding is the current locale. It is a no-brainer to not necessarily. current locale, encoding of current terminal and encoding of every filesystem mounted are all different things And we should stick to the current

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Alexey Khudyakov
On Sun, 27 Jun 2010 10:28:49 +0300 Roman Beslik ber...@ukr.net wrote: On 27.06.10 10:17, Bulat Ziganshin wrote: Sunday, June 27, 2010, 11:07:47 AM, you wrote: Currently, FilePath is an alias for String. Changing FilePath to a real type Just do not change FilePath, what may be simpler?

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

2010-06-27 Thread Max Bolingbroke
By the way, you can use this stuff to solve the restricted monad problem (e.g. make Set an instance of Monad). This is not that useful until we find out what the mother of all MonadPlus is, though, because we really need a MonadPlus Set instance. Code below. Cheers, Max \begin{code} {-#

Re: [Haskell-cafe] Space leak with unsafePerformIO

2010-06-27 Thread Bertram Felgenhauer
Henning Thielemann wrote: Attached is a program with a space leak that I do not understand. I have coded a simple 'map' function, once using unsafePerformIO and once without. UnsafePerformIO has a space leak in some circumstances. In the main program I demonstrate cases with and without space

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

2010-06-27 Thread Sjoerd Visscher
Hi Max, This is really interesting! 1. There exist total functions: lift :: X d = d a - D a lower :: X d = D a - d a 2. And you can write a valid instance: instance X D With *no superclass constraints*. All your examples have a more specific form: lift :: X d = d a - D d a

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

2010-06-27 Thread Sjoerd Visscher
Allowing Functor i also makes defining Thingy directly (without going though Monoidal) easy: newtype Thingy i a = Thingy { runThingy :: forall b. i (a - b) - i b } instance Functor i = Functor (Thingy i) where fmap f m = Thingy $ runThingy m . fmap (. f) instance Functor i = Applicative

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

2010-06-27 Thread Roman Leshchinskiy
On 27/06/2010, at 19:54, Max Bolingbroke wrote: Q: What is the mother of all X, where X is some type class? A: It is a data type D such that: 1. There exist total functions: lift :: X d = d a - D a lower :: X d = D a - d a Are those universally quantified over d? If so, then none of

Re: [Haskell-cafe] Core packages and locale support

2010-06-27 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 6/27/10 03:11 , Roman Beslik wrote: No! The target encoding is the current locale. It is a no-brainer to find it. Use your Unix. $ man setlocale $ locale So you want to use someone else's file, and their locale isn't the same as yours. What

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

2010-06-27 Thread Felipe Lessa
On Sun, Jun 27, 2010 at 10:54:08AM +0100, Max Bolingbroke wrote: Example 2: Codensity is the mother of all Monads I thought the continuation monad was the mother of all monads. :) For example, see [1]. Cheers! [1] http://blog.sigfpe.com/2008/12/mother-of-all-monads.html -- Felipe.

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 14:30, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: In that case, isn't D just the dictionary for (X d) and a value of type (d a)? I.e., couldn't we always define it as: data D d a where { D :: X d = d a - D d a } I wondered about this, but how would you write e.g. the

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 16:07, Felipe Lessa felipe.le...@gmail.com wrote: On Sun, Jun 27, 2010 at 10:54:08AM +0100, Max Bolingbroke wrote: Example 2: Codensity is the mother of all Monads I thought the continuation monad was the mother of all monads. :) I actually already referenced Dan's article,

Re: [Haskell-cafe] Space leak with unsafePerformIO

2010-06-27 Thread Henning Thielemann
On Sun, 27 Jun 2010, Bertram Felgenhauer wrote: If the compiler had produced Main.lvl3 = case Main.ds of wild_Xw { (prefix_aCf, suffix_aCh) - suffix_aCh } Main.lvl4 = Main.go1 Main.lvl3 instead, then there would not be a leak. This whole record selector thunk business is very

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

2010-06-27 Thread Sebastian Fischer
Hi Max, very interesting observations! By the way, you can use this stuff to solve the restricted monad problem (e.g. make Set an instance of Monad). This is not that useful until we find out what the mother of all MonadPlus is, though, because we really need a MonadPlus Set instance. I'm

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 13:16, Sjoerd Visscher sjo...@w3future.com wrote: Allowing Functor i also makes defining Thingy directly (without going though Monoidal) easy: newtype Thingy i a = Thingy { runThingy :: forall b. i (a - b) - i b } Great stuff! I particularly like your * definition, because it

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

2010-06-27 Thread David Menendez
On Sun, Jun 27, 2010 at 1:26 PM, Sebastian Fischer s...@informatik.uni-kiel.de wrote: Hi Max, very interesting observations! By the way, you can use this stuff to solve the restricted monad problem (e.g. make Set an instance of Monad). This is not that useful until we find out what the

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 18:28, Max Bolingbroke batterseapo...@hotmail.com wrote: I'm going to try automatically deriving a NBE algorithm for Moggi's monadic metalanguage from the Codensity monad - with luck it will correspond to the one-pass algorithm of Danvy. Well, that works. On second thoughts,

[Haskell-cafe] A little jewel on sigfpe's blog

2010-06-27 Thread Günther Schmidt
Hello, I just discovered this little jewel on Dan Piponi's blog. http://blog.sigfpe.com/2010/03/partial-ordering-of-some-category.html I'm just posting the link so that it doesn't get overlooked, would be a real shame. Günther ___ Haskell-Cafe

Re: [Haskell-cafe] Construction of short vectors

2010-06-27 Thread Alexey Khudyakov
On Sun, 27 Jun 2010 19:55:21 +1000 Roman Leshchinskiy r...@cse.unsw.edu.au wrote: On 25/06/2010, at 06:41, Alexey Khudyakov wrote: Then constructor like one below arise naturally. And I don't know how to write them properly. It's possible to use fromList but then list could be

[Haskell-cafe] Why this doesn't type checked

2010-06-27 Thread Victor Nazarov
I've allways found code like -- maxBound (undefined :: Int) a bit strange as any usage of undefined is. Being Ruby on Rails developer I've personally found that one of the main Rails motos is being as readable as possible. Code must be as close to english as possible. Embeded DSLs like rspec

Re: [Haskell-cafe] Construction of short vectors

2010-06-27 Thread Alexander Solla
On Jun 27, 2010, at 12:29 PM, Alexey Khudyakov wrote: This is of course faster but what I really want is vectors with length parametrized by type. This way I can write generic code. Uniform representation is requirement for that. You're going to need dependent types, or a similar

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 19:14, Max Bolingbroke batterseapo...@hotmail.com wrote: I'm going to try for normalisation of Lindleys idiom calculus now. Made me sweat, but I got it to work. From Thingy you get a free one-pass normaliser for idioms. Is this a novel result? It's certainly very cool! Term

Re: [Haskell-cafe] Why this doesn't type checked

2010-06-27 Thread Daniel Fischer
On Sunday 27 June 2010 21:52:18, Victor Nazarov wrote: I've allways found code like -- maxBound (undefined :: Int) a bit strange Well, that would indeed be a bit strange since maxBound :: (Bounded a) = a and function types aren't instances of Bounded, so it'd be maxBound :: Int maxBound

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

2010-06-27 Thread Edward Kmett
On Sun, Jun 27, 2010 at 6:25 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: By the way, you can use this stuff to solve the restricted monad problem (e.g. make Set an instance of Monad). This is not that useful until we find out what the mother of all MonadPlus is, though, because we

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

2010-06-27 Thread Edward Kmett
On Sun, Jun 27, 2010 at 7:43 AM, Sjoerd Visscher sjo...@w3future.comwrote: Hi Max, This is really interesting! 1. There exist total functions: lift :: X d = d a - D a lower :: X d = D a - d a 2. And you can write a valid instance: instance X D With *no superclass

Re: [Haskell-cafe] Construction of short vectors

2010-06-27 Thread Alexey Khudyakov
On Mon, Jun 28, 2010 at 12:00 AM, Alexander Solla a...@2piix.com wrote: On Jun 27, 2010, at 12:29 PM, Alexey Khudyakov wrote: This is of course faster but what I really want is vectors with length parametrized by type. This way I can write generic code. Uniform representation is requirement

Re: [Haskell-cafe] Re: Huffman Codes in Haskell

2010-06-27 Thread Bertram Felgenhauer
Andrew Bromage wrote: But honestly, it's just not that hard to do in linear time, assuming the symbols are sorted by frequency: Or maybe not so easy. But not much harder. data Tree a = Branch (Tree a) (Tree a) | Leaf a deriving Show huffmanTree :: (Ord a, Num a) = [(a,

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

2010-06-27 Thread Max Bolingbroke
On 27 June 2010 22:20, Edward Kmett ekm...@gmail.com wrote: I've pointed out the Codensity Set monad on the Haskell channel. I spend no time on #haskell but clearly I should :) It is an interesting novelty, but it unfortunately has somewhat funny semantics in that the intermediate sets that

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] Re: The mother of all functors/monads/categories

2010-06-27 Thread Edward Kmett
On Sun, Jun 27, 2010 at 6:45 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: On 27 June 2010 22:20, Edward Kmett ekm...@gmail.com wrote: I've pointed out the Codensity Set monad on the Haskell channel. I spend no time on #haskell but clearly I should :) It is an interesting

Re: [Haskell-cafe] Why this doesn't type checked

2010-06-27 Thread Ivan Miljenovic
On 28 June 2010 05:52, Victor Nazarov asviraspossi...@gmail.com wrote: Having this in my mind I've decided that this code should be rewritten without undefined being mentioned. But I need some type signature and it should mention Int type. So I've got an idea about what I've called fantom type

Re: [Haskell-cafe] Why this doesn't type checked

2010-06-27 Thread Victor Nazarov
On Mon, Jun 28, 2010 at 12:33 AM, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 27 June 2010 21:52:18, Victor Nazarov wrote: I've allways found code like -- maxBound (undefined :: Int) a bit strange Well, that would indeed be a bit strange since maxBound :: (Bounded a) = a