Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?
I can point you to the line of code causing you trouble[1]. The problem is, as you already pointed out, that we don't have a PersistValue constructor that fits this case correctly. I think the right solution is to go ahead and add such a constructor for the next release. I've opened a ticket on Github[2] to track this. By the way, not all databases supported by Persistent have the ability to represent NUMERIC with perfect precision. I'm fairly certain the SQLite will just cast to 8-byte reals, though it's possible that it will keep the data as strings in some circumstances. In the short term, you can probably get this to work today by turning your Fixed values into Integers (by multiplying by some power of 10) to marshaling to the database, and do the reverse when coming from the database. I haven't used this technique myself, but I think it should work. Michael [1] https://github.com/yesodweb/persistent/blob/master/persistent-postgresql/Database/Persist/Postgresql.hs#L271 [2] https://github.com/yesodweb/yesod/issues/493 On Fri, Jan 25, 2013 at 8:19 AM, s9gf4...@gmail.com wrote: ** All modern databases has field type NUMERIC(x, y) with arbitrary precision. I need to store financial data with absolute accuracy, and I decided to use Fixed. How can I store Fixed data type as NUMERIC ? I decided to use Snoyman's persistent, bit persistent can not use it from the box and there is a problem with custom field declaration. Here is the instance of PersistField for Fixed I wrote instance (HasResolution a) = PersistField (Fixed a) where toPersistValue a = PersistText $ T.pack $ show a -- fromPersistValue (PersistDouble d) = Right $ fromRational $ toRational d fromPersistValue (PersistText d) = case reads dpt of [(a, )] - Right a _ - Left $ T.pack $ Could not read value ++ dpt ++ as fixed value where dpt = T.unpack d fromPersistValue a = Left $ T.append Unexpected data value can not be converted to Fixed: $ T.pack $ show a sqlType a = SqlOther $ T.pack $ NUMERIC( ++ (show l) ++ , ++ (show p) ++ ) where p = round $ (log $ fromIntegral $ resolution a) / (log 10) l = p + 15 -- FIXME: this is maybe not very good isNullable _ = False I did not found any proper PersistValue to convert into Fixed from. As well as converting Fixed to PersistValue is just a converting to string. Anyway the saving works properly, but thre reading does not - it just reads Doubles with rounding error. If you uncomment the commented string in instance you will see, that accuracy is not absolute. Here is test project to demonstrate the problem. https://github.com/s9gf4ult/xres If you launch main you will see that precission is not very good because of converting database value to Double and then converting to Fixed. How can i solve this with persistent or what other framework works well with NUMERIC database field type ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Sequence and replicateM
Hi, isn't the correct type context for f the following? f :: (Functor m, Monad m) = Int - m a - m (Seq a) So your f really is a kind of specialization of g. Could the reason for f performing better be list fusion? Anything happening inside Control.Monad.replicateM should be subject to it. Cheers, Thomas Am 24.01.2013 15:31, schrieb Daniel Díaz Casanueva: Hi Cafe, I was coding this morning when I suddenly found something that surprised me. It's been a short time since I am really caring about the performance of my programs. Before, I was just caring about their correctness. So I am trying different things and profiling to see differences. One difference I have found surprising is that the function f is MUCH faster and less space consuming than the function g: import Control.Monad import qualified Data.Sequence as Seq type Seq = Seq.Seq f :: Monad m = Int - m a - m (Seq a) f n = fmap Seq.fromList . replicateM n g :: Monad m = Int - m a - m (Seq a) g = Seq.replicateM Maybe is just in my test case, where the Int argument is big and the monadic action short, but it looks to me that Data.Sequence.replicateM can be faster than it is right now. Regards, Daniel Díaz. -- E-mail sent by Daniel Díaz Casanueva let f x = x in x ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal install choosing an older version
Hi, I noticed a weird behaviour with cabal-install. When I run `cabal install hspec --dry-run -v` cabal-install correctly picks hspec-1.4.3 (the latest version). However, when I run `cabal install ansi-terminal hspec --dry-run -v`cabal-install tries to install hspec-0.3.0 for no apparent reason. This is with a clean user package db. Following is some info about my system. $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.1 $ cabal --version cabal-install version 1.16.0.2 using version 1.16.0.3 of the Cabal library $ ghc-pkg list --user $ cabal install hspec --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.5.5.1 (new package) hspec-expectations-0.3.0.3 (new package) random-1.0.1.1 (new package) QuickCheck-2.5.1.1 (new package) setenv-0.1.0 (new package) silently-1.2.4.1 (new package) transformers-0.3.0.0 (new package) hspec-1.4.3 (new package) $ cabal install ansi-terminal hspec --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.6 (new package) extensible-exceptions-0.1.1.4 (new package) random-1.0.1.1 (new package) QuickCheck-2.5 (new package) hspec-0.3.0 (new package) -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Sequence and replicateM
Yes, you're right about the type context. I always forget that Functor is not a superclass of Monad. Anyway, the `fmap` can be done only with `Monad` in the context. About the list fusion, I'm compiling with optimizations enabled (-O2), but I do not know how it works with fusions. Is it the optimization omitting the step of creating the list? How can I know it with certainty? On Fri, Jan 25, 2013 at 7:23 AM, Thomas Horstmeyer horst...@mathematik.uni-marburg.de wrote: Hi, isn't the correct type context for f the following? f :: (Functor m, Monad m) = Int - m a - m (Seq a) So your f really is a kind of specialization of g. Could the reason for f performing better be list fusion? Anything happening inside Control.Monad.replicateM should be subject to it. Cheers, Thomas Am 24.01.2013 15:31, schrieb Daniel Díaz Casanueva: Hi Cafe, I was coding this morning when I suddenly found something that surprised me. It's been a short time since I am really caring about the performance of my programs. Before, I was just caring about their correctness. So I am trying different things and profiling to see differences. One difference I have found surprising is that the function f is MUCH faster and less space consuming than the function g: import Control.Monad import qualified Data.Sequence as Seq type Seq = Seq.Seq f :: Monad m = Int - m a - m (Seq a) f n = fmap Seq.fromList . replicateM n g :: Monad m = Int - m a - m (Seq a) g = Seq.replicateM Maybe is just in my test case, where the Int argument is big and the monadic action short, but it looks to me that Data.Sequence.replicateM can be faster than it is right now. Regards, Daniel Díaz. -- E-mail sent by Daniel Díaz Casanueva let f x = x in x __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe -- E-mail sent by Daniel Díaz Casanueva let f x = x in x ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal install choosing an older version
Aha! I think I know why this happens. The latest versions of ansi-terminal and hspec do not work together. Cabal picks the latest ansi-terminal (0.6) first, then the latest hspec that doesn't conflict with this choice is 0.3.0. I can confirm this by the following: $ cabal install hspec ansi-terminal --dry-run -v Reading available packages... Choosing modular solver. Resolving dependencies... In order, the following would be installed: HUnit-1.2.5.1 (new package) ansi-terminal-0.5.5.1 (new package) hspec-expectations-0.3.0.3 (new package) random-1.0.1.1 (new package) QuickCheck-2.5.1.1 (new package) setenv-0.1.0 (new package) silently-1.2.4.1 (new package) transformers-0.3.0.0 (new package) hspec-1.4.3 (new package) When hspec comes before ansi-terminal, the latest version for hspec is selected and an older version of ansi-terminal is used. Maybe cabal-install should backtrack more and pick a *more optimal *set of latest versions, I don't know. If this is desired, a proximity of the selected versions to the latest available versions might be a good measure. Best, Ozgur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal install choosing an older version
On 25 January 2013 14:46, Ozgur Akgun ozgurak...@gmail.com wrote: The latest versions of ansi-terminal and hspec do not work together. Cabal picks the latest ansi-terminal (0.6) first, then the latest hspec that doesn't conflict with this choice is 0.3.0. If this happens because the dependency bounds of ansi-terminal are too tight then please send me a patch. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: gray-extended (tools for working with Gray codes)
I'm happy to announce a new package called gray-extended http://hackage.haskell.org/package/gray-extended-1.2 https://github.com/mhwombat/gray-extended (github) ABOUT GRAY-EXTENDED: Gray codes satisfy the property that two successive values differ in only one digit. Usually the term \Gray code\ refers to the Binary Reflected Gray code (BRGC), but non-binary Gray codes have also been discovered. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: creatur (framework for artificial life)
I'm happy to announce a new package called Créatúr (creatur) http://hackage.haskell.org/package/creatur https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf (tutorial) https://github.com/mhwombat/creatur (github) ABOUT CRÉATÚR: Créatúr is a software framework for automating experiments with artificial life (ALife) or other evolutionary algorithms (EA). It provides a daemon which ensures that each agent gets its turn to use the CPU. You can use other applications on the computer at the same time without fear of interfering with experiments; they will run normally (although perhaps more slowly). Créatúr also provides a library of modules to help you implement your own ALife species. Even if you aren't using the Créatúr framework, you may find some of these modules useful. A tutorial on how to use Créatúr, including lots of examples, is available at https://github.com/mhwombat/creatur-examples/raw/master/Tutorial.pdf. Créatúr (pronounced kray-toor) is an irish word meaning animal, creature, or unfortunate person. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: hslogstash (library for working with Logstash and related tools)
This is a library for sysadmins and/or tool writers. It provides proper types and correct serialization for Logstash messages, along with small utilities for working with ElasticSearch or Redis (using hedis). This library focus will be on safety (no messages lost). Right now, it can be used to: * send properly formated messages to Logstash * read Logstash messages from Redis or any socket * write Logstash messages to ElasticSearch or any socket This is the work of a sysadmin, thus very likely to be horrible to read. Suggestions are very welcome. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: hslogstash (library for working with Logstash and related tools)
For someone as lazy as myself: http://hackage.haskell.org/package/hslogstash https://github.com/bartavelle/hslogstash Cheers, On Fri, Jan 25, 2013 at 2:48 PM, Simon Marechal si...@banquise.net wrote: This is a library for sysadmins and/or tool writers. It provides proper types and correct serialization for Logstash messages, along with small utilities for working with ElasticSearch or Redis (using hedis). This library focus will be on safety (no messages lost). Right now, it can be used to: * send properly formated messages to Logstash * read Logstash messages from Redis or any socket * write Logstash messages to ElasticSearch or any socket This is the work of a sysadmin, thus very likely to be horrible to read. Suggestions are very welcome. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal install choosing an older version
Hi Max, On 25 January 2013 15:58, Max Bolingbroke batterseapo...@hotmail.comwrote: If this happens because the dependency bounds of ansi-terminal are too tight then please send me a patch. No, actually it happens because hspec depends on ansi-terminal-0.5.*. I am cc'ing Simon Hengel, the maintainer of hspec so he is aware of this. Best, Ozgur ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Sequence and replicateM
2013/1/25 Daniel Díaz Casanueva dhelta.d...@gmail.com Yes, you're right about the type context. I always forget that Functor is not a superclass of Monad. Anyway, the `fmap` can be done only with `Monad` in the context. Instead of adding `Functor m` constraint you could write just f n = liftM Seq.fromList . replicateM n Best regards, Petr Pudlak ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] why no replace function in our regular expression libs ?
People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? #haskell says: sclv iirc its because that's a really mutatey operation in the underlying c libs sclv should be simple enough to write a general purpose wrapper layer that uses captures to create the effect Secondly, as of today what do y'all do when you need that functionality ? -Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why no replace function in our regular expression libs ?
I've needed this recently, too. End result: I wrote an Attoparsec.Parser Text, and ran the text through that. A regex would have been much nicer... - Clark On Fri, Jan 25, 2013 at 2:06 PM, Simon Michael si...@joyful.com wrote: People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? #haskell says: sclv iirc its because that's a really mutatey operation in the underlying c libs sclv should be simple enough to write a general purpose wrapper layer that uses captures to create the effect Secondly, as of today what do y'all do when you need that functionality ? -Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?
turning your Fixed values into Integers Thanks for that idea.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ?
Hello, haskellers. I am trying to write some generic subtyping issue. Here upcast is always safe operation because of subtype is always behaves like the parrent type. downcast is not the safe becase of not every parrent type value can be converted to children type. Rangeable here is the typeclass of values in some range, so downcasting to Rang1 or Range2 or any other type, having instance for Rangeable can be done by checking if value is in proper range. The same for MultipleTo, downcasting can be done with checking if value is multiple to some value. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies, FlexibleContexts, UndecidableInstances, OverlappingInstances, IncoherentInstances #-} class SubtypeOf a b | a - b where upcast :: a - b downcastSafe :: b - Maybe a downcast :: b - a downcast b = case downcastSafe b of Nothing - error $ can not downcast the value Just a - a class (Ord a) = Rangable t a | t - a where lowLim :: t - a highLim :: t - a class Packable t a | t - a where pack :: a - t unpack :: t - a class MultipleTo t a | t - a where multiple :: t - a instance (Num a, Ord a, Rangable range a, Packable range a) = SubtypeOf range a where upcast = unpack downcastSafe b | b = (lowLim $ pb) b = (highLim $ pb) = Just $ pb | otherwise = Nothing where pb = pack b instance (Integral a, Packable range a, MultipleTo range a) = SubtypeOf range a where upcast = unpack downcastSafe b | b `mod` (multiple pb) == 0 = Just pb | otherwise = Nothing where pb = pack b newtype Range1 a = Range1 {unRange1 :: a} deriving Show instance (Num a, Ord a) = Rangable (Range1 a) a where lowLim _ = 0 highLim _ = 10 instance (Num a, Ord a) = Packable (Range1 a) a where pack = Range1 unpack = unRange1 newtype Range2 a = Range2 {unRange2 :: a} deriving Show instance (Num a, Ord a) = Rangable (Range2 a) a where lowLim _ = -10 highLim _ = 200 instance (Num a, Ord a) = Packable (Range2 a) a where pack = Range2 unpack = unRange2 but there is compilation error: Duplicate instance declarations: instance [incoherent] (Num a, Ord a, Rangable range a, Packable range a) = SubtypeOf range a -- Defined at ...:22:10 instance [incoherent] (Integral a, Packable range a, MultipleTo range a) = SubtypeOf range a -- Defined at ...:29:10 Failed, modules loaded: none. If I remove one of instances of SubtypeOf the program is compiling. How to write this instances properly, or to write proper type casting ? Thanks PS. My english is not very good, but I hope this is understandable.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ?
On Fri, Jan 25, 2013 at 3:18 PM, s9gf4...@gmail.com wrote: Duplicate instance declarations: instance [incoherent] (Num a, Ord a, Rangable range a, Packable range a) = SubtypeOf range a -- Defined at ...:22:10 instance [incoherent] (Integral a, Packable range a, MultipleTo range a) = SubtypeOf range a -- Defined at ...:29:10 This would be correct. Constraints on an instance are applied *after* the instance is selected, so when Haskell is looking for an instance, these two are identical. This has the code smell of trying to use typeclasses for OOP. That won't work. (Yes, really.) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ?
This has the code smell of trying to use typeclasses for OOP. That won't work. (Yes, really.) I am not trying to use OOP, I am just writing some typecasting at all. This would be correct. Constraints on an instance are applied *after* the instance is selected, so when Haskell is looking for an instance, these two are identical. I didn't understand why these two instances are identical ? The constraints are different and OverlappingInstances should permit overlapping typeclasses in constraints and select more specific instance clause.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: monad-bool 0.1
On 1/24/13 1:40 AM, Ertugrul Söylemez wrote: David Thomas davidleotho...@gmail.com wrote: We could even set up NotOnHackage: a package repository just like Hackage, except the packages are just documentation on why there is no such package. Implementation-wise it's just a wiki; but the idea is about how to organize the wiki. NotOnHackage should be organized and searchable similar to Hackage itself, so that people can look there when nothing looks promising on Hackage. Couldn't this be actually on hackage, so one search turns up what you want? Yes. There is no reason to put up a second Hackage for that one. Without changing anything in the current system, packages can just update their categories, so that they will be displayed below Defunct or something like that. This is fine, as only the categories of the latest version are significant. If you think this is a good idea, I will start with some of my packages. =) We've had package deprecation for a while, so the big trick IMO is the documentation. Good descriptions of why the package is defunct and suggestions on how people can do things better. If we're going to do it on Hackage itself, I think the big question is one of style: should the documentation be all in the cabal file (i.e., on the package description page, with no modules in the package); or should we put the documentation into modules? -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: monad-bool 0.1
I think it needs to be both places. I know when I'm searching, I often just go to google with site:hackage.haskell.org inurl:latest I would be likely to miss it if it were just in the cabal file (although in the modules it could be as simple as a note saying this is defunct - view the main page for an explanation of why). Alternatively, if there is much reasoning specific to a particular module it could certainly go there, while the cabal gets the overview... On Fri, Jan 25, 2013 at 3:23 PM, wren ng thornton w...@freegeek.org wrote: On 1/24/13 1:40 AM, Ertugrul Söylemez wrote: David Thomas davidleotho...@gmail.com wrote: We could even set up NotOnHackage: a package repository just like Hackage, except the packages are just documentation on why there is no such package. Implementation-wise it's just a wiki; but the idea is about how to organize the wiki. NotOnHackage should be organized and searchable similar to Hackage itself, so that people can look there when nothing looks promising on Hackage. Couldn't this be actually on hackage, so one search turns up what you want? Yes. There is no reason to put up a second Hackage for that one. Without changing anything in the current system, packages can just update their categories, so that they will be displayed below Defunct or something like that. This is fine, as only the categories of the latest version are significant. If you think this is a good idea, I will start with some of my packages. =) We've had package deprecation for a while, so the big trick IMO is the documentation. Good descriptions of why the package is defunct and suggestions on how people can do things better. If we're going to do it on Hackage itself, I think the big question is one of style: should the documentation be all in the cabal file (i.e., on the package description page, with no modules in the package); or should we put the documentation into modules? -- Live well, ~wren __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why no replace function in our regular expression libs ?
On 13-01-25 02:06 PM, Simon Michael wrote: People have put a lot of work into regular expression libraries on haskell. Yet it seems very few of them provide a replace/substitute function - just regex-compat and regepr as far as I know. Why is that ? [...] Secondly, as of today what do y'all do when you need that functionality I can only speak for myself, why I do not miss regex substitution too much. Sometimes, regex substitution is exactly the solution, and I use it. But the whole job is easily done in a shell script, or even in an editor. So I don't use regex substitution in Haskell in this case. Sometimes, the substitution job is: transform this article titlecodeMonad/code Tutorial/title content.../content /article to this !DOCTYPE html etc etc html headtitleMonad Tutorial/title/head body h1codeMonad/code Tutorial/h1 ... /body /html In this job, if a regex solution exists, I don't want to know. I just use HXT or XSLT. Sometimes, regex substitution plus Haskell is exactly the solution. Then I use regex-compat. It works. One solution is enough. I don't need a hundred choices for regex, or a hundred choices for Int. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?
By the way, not all databases supported by Persistent have the ability to represent NUMERIC with perfect precision. I'm fairly certain the SQLite will just cast to 8-byte reals, though it's possible that it will keep the data as strings in some circumstances. According to the documentation, SQLite stores whatever you give it, paying very little heed to the declared type. If you get SQLite to *compare* two numbers, it will at that point *convert* them to doubles in order to carry out the comparison. This is quite separate from the question of what it can store. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: monad-bool 0.1
A brief stylistic note: to me, defunct has a connotation similar to that of deprecated, just stronger; meaning, it implies something closer to NoLongerOnHackage rather than wren's more general NotOnHackage. In this case, the distinction is moot, because the code did happen to exist on Hackage, but I imagine there are cases one might want to warn against without this condition being true. On Fri, Jan 25, 2013 at 6:32 PM, David Thomas davidleotho...@gmail.comwrote: I think it needs to be both places. I know when I'm searching, I often just go to google with site:hackage.haskell.org inurl:latest I would be likely to miss it if it were just in the cabal file (although in the modules it could be as simple as a note saying this is defunct - view the main page for an explanation of why). Alternatively, if there is much reasoning specific to a particular module it could certainly go there, while the cabal gets the overview... On Fri, Jan 25, 2013 at 3:23 PM, wren ng thornton w...@freegeek.orgwrote: On 1/24/13 1:40 AM, Ertugrul Söylemez wrote: David Thomas davidleotho...@gmail.com wrote: We could even set up NotOnHackage: a package repository just like Hackage, except the packages are just documentation on why there is no such package. Implementation-wise it's just a wiki; but the idea is about how to organize the wiki. NotOnHackage should be organized and searchable similar to Hackage itself, so that people can look there when nothing looks promising on Hackage. Couldn't this be actually on hackage, so one search turns up what you want? Yes. There is no reason to put up a second Hackage for that one. Without changing anything in the current system, packages can just update their categories, so that they will be displayed below Defunct or something like that. This is fine, as only the categories of the latest version are significant. If you think this is a good idea, I will start with some of my packages. =) We've had package deprecation for a while, so the big trick IMO is the documentation. Good descriptions of why the package is defunct and suggestions on how people can do things better. If we're going to do it on Hackage itself, I think the big question is one of style: should the documentation be all in the cabal file (i.e., on the package description page, with no modules in the package); or should we put the documentation into modules? -- Live well, ~wren __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ?
http://ideone.com/v2CrAm I has posted to ideone to show what is wrong.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to escape from typecheck error: Duplicate instance declarations ?
On Fri, Jan 25, 2013 at 12:39 PM, s9gf4...@gmail.com wrote: ** This has the code smell of trying to use typeclasses for OOP. That won't work. (Yes, really.) I am not trying to use OOP, I am just writing some typecasting at all. This would be correct. Constraints on an instance are applied *after* the instance is selected, so when Haskell is looking for an instance, these two are identical. I didn't understand why these two instances are identical ? The constraints are different and OverlappingInstances should permit overlapping typeclasses in constraints and select more specific instance clause. They are identical because constraints don't count for deciding that a type is in a class. For the purposes of deciding if a type is in a class, instance Foo (Bar a) instance Fizz a = Foo (Bar a) instance Fuzz a = Foo (Bar a) are exactly the same, and all three are therefore overlapping instances. None is more specific, because they all refer to the same type -- (Bar a). Also, you can just use Typeable instead of that downcasting stuff. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?
According to the documentation, SQLite stores whatever you give it, paying very little heed to the declared type. If you get SQLite to *compare* two numbers, it will at that point *convert* them to doubles in order to carry out the comparison. This is quite separate from the question of what it can store. CREATE TABLE t1(val); sqlite insert into t1 values ('24.24242424') ... ; sqlite insert into t1 values ('24.24242423') ... ; sqlite select * from t1 order by val; 24.24242423 24.24242424 sqlite select * from t1 order by val desc; 24.24242424 24.24242423 sqlite select sum(val) from t1; 48.48484847 it seems Sqlite can work with arbitrary percission data, very good ! Persistent must have ability to store Fixed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe