Re: [Haskell-cafe] ANNOUNCE: Haskell BOF on 29c3 in Hamburg, Germany
Hey, sounds interesting, I'll be there :) Also, HTML in the description doesn't seem to work, you might want to add the links as footnotes or something. Koomi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type error when trying to adapt http-proxy to new conduit
On Thu, Dec 27, 2012 at 9:42 AM, Erik de Castro Lopo wrote: > Pieter Laeremans wrote: > > > Hi, > > > > The http-proxy package isn't compatible any longer with the latest > > conduit. Since it is open source, I thought, I might as well try to adapt > > it and submit a patch. > > Have you looked int git? > > It currently compiles from git but there is a space leak that > I haven't managed to fix yet. > > Erik > -- > -- > Erik de Castro Lopo > http://www.mega-nerd.com/ > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Hi Erik, I remember discussing very briefly with you why it wasn't possible to simply use warp as a library for this project. I wonder if there would be a way to expose more functionality from warp to make the maintenance burden easier for http-proxy going forward. I'll be on IRC in a bit if you'd like to discuss it. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
Prelude> :t [[1,2],3] you have a list with 2 elements: - [1,2] - 3 the type of [1,2] is [Integer] the type of 3 is Integer But all elements in a list must have the same type. 2012/12/27 Rustom Mody : > > > On Thu, Dec 27, 2012 at 1:48 AM, Roman Cheplyaka wrote: >> >> * Rustom Mody [2012-12-26 20:12:17+0530] >> > So is there any set of flags to make haskell literals less polymorphic? >> >> Yes, there is! >> >> % ghci -XRebindableSyntax >> GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help >> Loading package ghc-prim ... linking ... done. >> Loading package integer-gmp ... linking ... done. >> Loading package base ... linking ... done. >> > import Prelude hiding (fromInteger) >> Prelude> let fromInteger = id >> Prelude> :t 3 >> 3 :: Integer >> >> Roman > > > > Thanks Roman -- that helps. > And yet the ghci error is much more obscure than the gofer error: > > --- contents of .ghci --- > :set -XRebindableSyntax > let fromInteger = id > -- ghci session - > $ ghci > GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help > > Loading package ghc-prim ... linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Prelude> :t 5 > 5 :: Integer > Prelude> :t [[1,2],3] > > :1:8: > Couldn't match expected type `[Integer]' with actual type `Integer' > Expected type: Integer -> [Integer] > Actual type: Integer -> Integer > In the expression: 3 > In the expression: [[1, 2], 3] > > > - The same in gofer - > Gofer session for: > pustd.pre > ? :t [[1,2],3] > > > ERROR: Type error in list > *** expression : [[1,2],3] > > *** term : 3 > *** type : Int > *** does not match : [Int] > -- > So the error is occurring at the point of the fromInteger (= id) but the > message does not indicate that > > -- > http://www.the-magus.in > http://blog.languager.org > > > ___ > 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] Non polymorphic numerals option -- avoiding type classes
Hi David, it looks like Rustom's aware that haskell's not lisp. What he really wants methinks is a way to suppress type classes altogether! That or a NoOverloadedNumerals extension. -- Kim-Ee On Thu, Dec 27, 2012 at 4:03 PM, David Virebayre wrote: > Prelude> :t [[1,2],3] > > you have a list with 2 elements: > - [1,2] > - 3 > the type of [1,2] is [Integer] > the type of 3 is Integer > > But all elements in a list must have the same type. > > > > > > 2012/12/27 Rustom Mody : > > > > > > On Thu, Dec 27, 2012 at 1:48 AM, Roman Cheplyaka > wrote: > >> > >> * Rustom Mody [2012-12-26 20:12:17+0530] > >> > So is there any set of flags to make haskell literals less > polymorphic? > >> > >> Yes, there is! > >> > >> % ghci -XRebindableSyntax > >> GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help > >> Loading package ghc-prim ... linking ... done. > >> Loading package integer-gmp ... linking ... done. > >> Loading package base ... linking ... done. > >> > import Prelude hiding (fromInteger) > >> Prelude> let fromInteger = id > >> Prelude> :t 3 > >> 3 :: Integer > >> > >> Roman > > > > > > > > Thanks Roman -- that helps. > > And yet the ghci error is much more obscure than the gofer error: > > > > --- contents of .ghci --- > > :set -XRebindableSyntax > > let fromInteger = id > > -- ghci session - > > $ ghci > > GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help > > > > Loading package ghc-prim ... linking ... done. > > Loading package integer-gmp ... linking ... done. > > Loading package base ... linking ... done. > > Prelude> :t 5 > > 5 :: Integer > > Prelude> :t [[1,2],3] > > > > :1:8: > > Couldn't match expected type `[Integer]' with actual type `Integer' > > Expected type: Integer -> [Integer] > > Actual type: Integer -> Integer > > In the expression: 3 > > In the expression: [[1, 2], 3] > > > > > > - The same in gofer - > > Gofer session for: > > pustd.pre > > ? :t [[1,2],3] > > > > > > ERROR: Type error in list > > *** expression : [[1,2],3] > > > > *** term : 3 > > *** type : Int > > *** does not match : [Int] > > -- > > So the error is occurring at the point of the fromInteger (= id) but the > > message does not indicate that > > > > -- > > http://www.the-magus.in > > http://blog.languager.org > > > > > > ___ > > 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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Virthualenv/HsEnv in Windows
Kyle Hanson, Mon 2012-12-24 @ 15:49:44-0600: > Has anyone gotten this to work on Windows either native or on cygwin? > Is there an alternative? It may work on Cygwin, but I know for sure that it wouldn't run natively on Windows, as part of hsenv's functionality involves generating and executing bash scripts. If you've tried it with Cygwin and it didn't work, maybe give some more detail about the problems you're seeing. I am unable to try it out myself as I don't have any Windows machines, but others might be able to offer some insight. signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh wrote: > Hi David, it looks like Rustom's aware that haskell's not lisp. What he > really wants methinks is a way to suppress type classes altogether! That or > a NoOverloadedNumerals extension. > > -- Kim-Ee > > I'm not really sure about that... Look! ghci with default startup $ ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :t [[1,2],3] [[1,2],3] :: (Num [t], Num t) => [[t]] So it would appear that ghci is giving a well-typing for [[1,2], 3]. But is it? Prelude> [[1,2],3] :3:8: No instance for (Num [t0]) arising from the literal `3' Possible fix: add an instance declaration for (Num [t0]) In the expression: 3 In the expression: [[1, 2], 3] In an equation for `it': it = [[1, 2], 3] --- So is it well-typed in ghci or not?? And now we add Roman's suggestions... $ cat .ghci :set -XRebindableSyntax let fromInteger = id And run ghci again $ ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :t [[1,2],3] :1:8: Couldn't match expected type `[Integer]' with actual type `Integer' Expected type: Integer -> [Integer] Actual type: Integer -> Integer In the expression: 3 In the expression: [[1, 2], 3] Prelude> [[1,2],3] :3:8: Couldn't match expected type `[Integer]' with actual type `Integer' Expected type: Integer -> [Integer] Actual type: Integer -> Integer In the expression: 3 In the expression: [[1, 2], 3] Prelude> So far so good -- when an expression is type-wrong, its 'wrongness' is the same irrespective of whether I ask for its type or evaluate it. But now we are in for new surprises: Try out f x y = x / y Prelude> :l f [1 of 1] Compiling Main ( f.hs, interpreted ) f.hs:1:11: Not in scope: `/' Failed, modules loaded: none. Prelude> (/) Oh is it that now integer literals are just plain Integers and cant be divided using '/' ?? So lets replace '/' with '+' f.hs:1:11: Not in scope: `+' And now I am at my wits end! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: haskell-docs - Given a module name and a name, it will find and display the documentation of that name.
This is something I always missed. Thank you! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
I don't know about the RebindableSyntax extension. But Prelude> :t [[1,2],3] [[1,2],3] :: (Num [t], Num t) => [[t]] The above only says that is is possible to have a list like [[1,2],3] if you have for a Num t, [t] is also an instance of Num. But it doesn't guarantee the existence of such an instance. When you actually execute the code then you see that no such instance exists by default. -Satvik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
* Rustom Mody [2012-12-27 22:18:15+0530] > But now we are in for new surprises: Try out > f x y = x / y > Prelude> :l f > [1 of 1] Compiling Main ( f.hs, interpreted ) > > f.hs:1:11: Not in scope: `/' > Failed, modules loaded: none. > Prelude> (/) It's because RebindableSyntax implies NoImplicitPrelude. This is not an issue if you only work in the interpreter (you can put "import Prelude hiding (fromInteger)" in .ghci), but you'd also need to put that into every source file that you wish to load. An alternative would be to create your own Prelude (or use an existing one, like [1]) and use it instead of the one defined in base (by hiding base and exposing a different package). [1]: http://hackage.haskell.org/packages/archive/simpleprelude/1.0.1.3/doc/html/Prelude.html Roman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
Forgot to say: if you go the first route, you'll also need to define your fromInteger in every module — the one from .ghci won't be in scope. You can define module MyPrelude (module Prelude, fromInteger) where import Prelude hiding (fromInteger) fromInteger = id and import it instead. * Roman Cheplyaka [2012-12-27 19:22:53+0200] > * Rustom Mody [2012-12-27 22:18:15+0530] > > But now we are in for new surprises: Try out > > f x y = x / y > > Prelude> :l f > > [1 of 1] Compiling Main ( f.hs, interpreted ) > > > > f.hs:1:11: Not in scope: `/' > > Failed, modules loaded: none. > > Prelude> (/) > > It's because RebindableSyntax implies NoImplicitPrelude. This is not an > issue if you only work in the interpreter (you can put "import Prelude > hiding (fromInteger)" in .ghci), but you'd also need to put that into > every source file that you wish to load. > > An alternative would be to create your own Prelude (or use an existing > one, like [1]) and use it instead of the one defined in base (by hiding > base and exposing a different package). > > [1]: > http://hackage.haskell.org/packages/archive/simpleprelude/1.0.1.3/doc/html/Prelude.html > > Roman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: haskell-docs - Given a module name and a name, it will find and display the documentation of that name.
Thanks, this is great! Tom Sent from my iPhone On Dec 26, 2012, at 7:43 PM, Christopher Done wrote: > Ahoy hoy, > > Just thought I'd announce a tool I whipped up these evening to take a > module name and a name and output the installed Haddock documentation > for it. Examples with my GHCi session: > > λ> :doc Data.List.Split split > Split a list according to the given splitting strategy. This is > how to "run" a Splitter that has been built using the other > combinators. > λ> :doc Control.Concurrent.MVar swapMVar > Take a value from an MVar, put a new value into the MVar and > return the value taken. This function is atomic only if there are > no other producers for this MVar. > λ> :doc Data.List sort > Ambiguous module, belongs to more than one package: base haskell2010-1.1.0.1 > Continuing anyway... > Package: base > The sort function implements a stable sorting algorithm. > It is a special case of sortBy, which allows the programmer to supply > their own comparison function. > > Please have a play with it, the package is at: > http://hackage.haskell.org/package/haskell-docs It has installation > instructions. Feel free to share any issues that you have, either > here, or on the Github page: https://github.com/chrisdone/haskell-docs > There are some issues to do with versioning that I'm not sure how to > solve in a standard way. > > The obvious next step is to have a -package-conf flag so that it can > be used with cabal-dev. > > The wizards on #haskell are currently thinking of a way to avoid > having to write the module name and just use what's in scope. > > Ciao! > > ___ > 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] Decent docs to my visualization tools
Hi cafe, I just finally published a decent documentation website and binary distributions for my log visualization tools written in Haskell - http://jkff.info/software/timeplotters/ . I think now they might actually stand a chance of starting to be adopted by a wider circle than my friends :) Feedback and sharing would be very welcome. -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Documentation operator
Hi, I think that this is a neat idea that should be explored more! GHC's parser has a bunch of awkward duplication to handle attaching documentation to types, and it'd be cool if we could replace it with an actual language construct. Happy holidays! -Iavor On Wed, Dec 26, 2012 at 3:27 AM, Christopher Done wrote: > Hello chums, > > I've been playing around with an idea, something that has obvious pros > and cons, but I'll sell it to you because there might be some positive > ideas out of it. Consider the following operator: > > {-# LANGUAGE TypeOperators, DataKinds, KindSignatures #-} > > module Docs where > > import GHC.TypeLits > > type a ? (sym :: Symbol) = a > > First I'll describe how I'd want to use this and then what I think > are the advantages and disadvantages. > > I call this (?) operator “the documentation operator”, to be used for: > > * Things that either don't belong or can't be encoded in the type > system, or for things need to be in English. > * Things that cannot be encoded in Haddock. > > The simple case of ye olde days: > > -- | Lorem ipsum dolor sit amet. Suspendisse lacinia nibh et > -- leo. Aenean auctor aliquam dapibus. > loremIpsum :: Int -> Int -> String > > Which has since been somewhat evolved into: > > loremIpsum :: Int-- ^ Lorem ipsum dolor sit amet. >-> Int-- ^ Suspendisse lacinia nibh et leo. >-> String -- ^ Aenean auctor aliquam dapibus. > > But could now be written: > > loremIpsum :: Int? "Lorem ipsum dolor sit amet." >-> Int? "Suspendisse lacinia nibh et leo." >-> String ? "Aenean auctor aliquam dapibus." > > Here is a contrived case I'll use later on: > > data Person = Person > > describeAge :: Int ? "an age" -> String ? "description of their > elderliness" > describeAge n = undefined > > personAge :: Person ? "a person" -> Int ? "their age" > personAge = undefined > > One could also encode previously informal specifications more formally, > so that > > -- | The action 'hFlush' @hdl@ causes any items buffered for output > -- in handle @hdl@ to be sent immediately to the operating system. > -- > -- This operation may fail with: > -- > -- * 'isFullError' if the device is full; > -- > -- * 'isPermissionError' if a system resource limit would be exceeded. > --It is unspecified whether the characters in the buffer are > discarded > --or retained under these circumstances. > hFlush :: Handle -> IO () > hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer > > with > > type Throws ex (docs :: Symbol) = docs > > could now be written > > hFlush :: Handle ? "flush buffered items for output on this handle" -> > IO () > ? Throws IsFullError "if the device is full" > ? Throws IsPermissionError >"if a system resource limit would be exceeded. It is \ >\unspecified whether the characters in the buffer are \ >\discarded or retained under these circumstances." > hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer > > With this in place, in GHCi you get documentation "lookup" for free: > > > :t hFlush > hFlush > :: (Handle ? "flush buffered items for output on this handle") > -> (IO () ? Throws IsFullError "if the device is full") > ? Throws > IsPermissionError > "if a system resource limit would be exceeded. It is > unspecified > whether the characters in the buffer are discarded or > retained > under these circumstances." > > And you get function composition, or “documentation composition” for free: > > > :t describeAge . personAge > describeAge . personAge > :: (Person ? "a person") > -> String ? "description of their elderliness" > > We could have a :td command to print it with docs, and otherwise docs > could be stripped out trivially by removing the ? annotations: > > > :t describeAge . personAge > describeAge . personAge > :: Person -> String > > :td describeAge . personAge > describeAge . personAge > :: (Person ? "a person") > -> String ? "description of their elderliness" > > You could even add clever printing of such “documentation types”: > > > :t hFlush > hFlush > :: Handle — flush buffered items for output on this handle > -> IO () > Throws IsFullError if the device is full" > Throws IsPermissionError if a system resource limit would be > exceeded. It is unspecified whether the characters in the buffer > are discarded or retained under these circumstances." > > Unfortunately it doesn't work with monadic composition, of course. > > So here are the advantages: > > * You get parsing for free (and anyone using haskell-src-exts). > * You get checking for free (i.e. GHC can check that Is
Re: [Haskell-cafe] Documentation operator
I love the idea, but it seems like it's a bit too early in Haskell's life to implement it. Not everyone's on GHC 7.6.1+. - Clark On Thu, Dec 27, 2012 at 3:20 PM, Iavor Diatchki wrote: > Hi, > > I think that this is a neat idea that should be explored more! GHC's > parser has a bunch of awkward duplication to handle attaching documentation > to types, and it'd be cool if we could replace it with an actual language > construct. > > Happy holidays! > -Iavor > > On Wed, Dec 26, 2012 at 3:27 AM, Christopher Done wrote: > >> Hello chums, >> >> I've been playing around with an idea, something that has obvious pros >> and cons, but I'll sell it to you because there might be some positive >> ideas out of it. Consider the following operator: >> >> {-# LANGUAGE TypeOperators, DataKinds, KindSignatures #-} >> >> module Docs where >> >> import GHC.TypeLits >> >> type a ? (sym :: Symbol) = a >> >> First I'll describe how I'd want to use this and then what I think >> are the advantages and disadvantages. >> >> I call this (?) operator “the documentation operator”, to be used for: >> >> * Things that either don't belong or can't be encoded in the type >> system, or for things need to be in English. >> * Things that cannot be encoded in Haddock. >> >> The simple case of ye olde days: >> >> -- | Lorem ipsum dolor sit amet. Suspendisse lacinia nibh et >> -- leo. Aenean auctor aliquam dapibus. >> loremIpsum :: Int -> Int -> String >> >> Which has since been somewhat evolved into: >> >> loremIpsum :: Int-- ^ Lorem ipsum dolor sit amet. >>-> Int-- ^ Suspendisse lacinia nibh et leo. >>-> String -- ^ Aenean auctor aliquam dapibus. >> >> But could now be written: >> >> loremIpsum :: Int? "Lorem ipsum dolor sit amet." >>-> Int? "Suspendisse lacinia nibh et leo." >>-> String ? "Aenean auctor aliquam dapibus." >> >> Here is a contrived case I'll use later on: >> >> data Person = Person >> >> describeAge :: Int ? "an age" -> String ? "description of their >> elderliness" >> describeAge n = undefined >> >> personAge :: Person ? "a person" -> Int ? "their age" >> personAge = undefined >> >> One could also encode previously informal specifications more formally, >> so that >> >> -- | The action 'hFlush' @hdl@ causes any items buffered for output >> -- in handle @hdl@ to be sent immediately to the operating system. >> -- >> -- This operation may fail with: >> -- >> -- * 'isFullError' if the device is full; >> -- >> -- * 'isPermissionError' if a system resource limit would be >> exceeded. >> --It is unspecified whether the characters in the buffer are >> discarded >> --or retained under these circumstances. >> hFlush :: Handle -> IO () >> hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer >> >> with >> >> type Throws ex (docs :: Symbol) = docs >> >> could now be written >> >> hFlush :: Handle ? "flush buffered items for output on this handle" >> -> IO () >> ? Throws IsFullError "if the device is full" >> ? Throws IsPermissionError >>"if a system resource limit would be exceeded. It is \ >>\unspecified whether the characters in the buffer are \ >>\discarded or retained under these circumstances." >> hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer >> >> With this in place, in GHCi you get documentation "lookup" for free: >> >> > :t hFlush >> hFlush >> :: (Handle ? "flush buffered items for output on this handle") >> -> (IO () ? Throws IsFullError "if the device is full") >> ? Throws >> IsPermissionError >> "if a system resource limit would be exceeded. It is >> unspecified >> whether the characters in the buffer are discarded or >> retained >> under these circumstances." >> >> And you get function composition, or “documentation composition” for free: >> >> > :t describeAge . personAge >> describeAge . personAge >> :: (Person ? "a person") >> -> String ? "description of their elderliness" >> >> We could have a :td command to print it with docs, and otherwise docs >> could be stripped out trivially by removing the ? annotations: >> >> > :t describeAge . personAge >> describeAge . personAge >> :: Person -> String >> > :td describeAge . personAge >> describeAge . personAge >> :: (Person ? "a person") >> -> String ? "description of their elderliness" >> >> You could even add clever printing of such “documentation types”: >> >> > :t hFlush >> hFlush >> :: Handle — flush buffered items for output on this handle >> -> IO () >> Throws IsFullError if the device is full" >> Throws IsPermissionError if a system resource limit would be >> exceeded. It is u
Re: [Haskell-cafe] Non polymorphic numerals option -- avoiding type classes
On Thu, Dec 27, 2012 at 11:48 PM, Rustom Mody wrote: > On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh wrote: >> What he really wants methinks is a way to suppress type classes altogether! That or a NoOverloadedNumerals extension. > > I'm not really sure about that... Look! > > Prelude> :t [[1,2],3] > [[1,2],3] :: (Num [t], Num t) => [[t]] As Satvik explained, well-typed does not imply instantiable. And with constraints, not instantiable /does/ imply not evaluable! > :set -XRebindableSyntax > let fromInteger = id > Prelude> :t [[1,2],3] > > Couldn't match expected type `[Integer]' with actual type `Integer' > Expected type: Integer -> [Integer] > Actual type: Integer -> Integer > In the expression: 3 > In the expression: [[1, 2], 3] You can see overloaded numerals at work again via the hidden hand of fromInteger. Presumably some imaginary NoOverloadedNumerals extension would thoroughly purge its presence. -- Kim-Ee On Thu, Dec 27, 2012 at 11:48 PM, Rustom Mody wrote: > > On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh wrote: >> >> Hi David, it looks like Rustom's aware that haskell's not lisp. What he really wants methinks is a way to suppress type classes altogether! That or a NoOverloadedNumerals extension. >> >> -- Kim-Ee >> > > I'm not really sure about that... Look! > > ghci with default startup > > > $ ghci > GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Prelude> :t [[1,2],3] > [[1,2],3] :: (Num [t], Num t) => [[t]] > > So it would appear that ghci is giving a well-typing for [[1,2], 3]. > But is it? > > Prelude> [[1,2],3] > > :3:8: > > No instance for (Num [t0]) > arising from the literal `3' > > Possible fix: add an instance declaration for (Num [t0]) > In the expression: 3 > In the expression: [[1, 2], 3] > In an equation for `it': it = [[1, 2], 3] > --- > So is it well-typed in ghci or not?? > > And now we add Roman's suggestions... > $ cat .ghci > > :set -XRebindableSyntax > let fromInteger = id > > And run ghci again > > > $ ghci > GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Prelude> :t [[1,2],3] > > :1:8: > Couldn't match expected type `[Integer]' with actual type `Integer' > Expected type: Integer -> [Integer] > Actual type: Integer -> Integer > In the expression: 3 > In the expression: [[1, 2], 3] > Prelude> [[1,2],3] > > :3:8: > > Couldn't match expected type `[Integer]' with actual type `Integer' > Expected type: Integer -> [Integer] > Actual type: Integer -> Integer > In the expression: 3 > In the expression: [[1, 2], 3] > Prelude> > > So far so good -- when an expression is type-wrong, its 'wrongness' is the same irrespective of whether I ask for its type or evaluate it. > > But now we are in for new surprises: Try out > f x y = x / y > Prelude> :l f > [1 of 1] Compiling Main ( f.hs, interpreted ) > > f.hs:1:11: Not in scope: `/' > Failed, modules loaded: none. > Prelude> (/) > > Oh is it that now integer literals are just plain Integers and cant be divided using '/' ?? > > So lets replace '/' with '+' > f.hs:1:11: Not in scope: `+' > > And now I am at my wits end! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] my Fasta is slow ;(
On Tue, Dec 18, 2012 at 12:42 PM, Branimir Maksimovic wrote: > > Seems to me that culprit is in function random as I have tested rest of > code > and didn't found speed related problems. > The problem with your original program was that it was not pure enough. Because you stored your PRNG state in an IORef, you forced the program to allocate and case-inspect boxed Ints in its inner loop. I refactored it slightly to make genRand and genRandom pure, and combined with using the LLVM back end, this doubled the program's performance, so that the Haskell program ran at the same speed as your C++ version. The next bottleneck was that your program was performing floating point arithmetic in the inner loop. I changed it to precompute a small lookup table, followed by only using integer arithmetic in the inner loop (the same technique used by the fastest C fasta program). This further improved performance: the new Haskell code is 40% faster than the C++ program, and only ~20% slower than the C program that currently tops the shootout chart. The Haskell source is a little over half the size of the C source. You can follow the work I did here: https://github.com/bos/shootout-fasta ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Gloss and relatively expensive computations
Hello cafe! I'm having some performance issues trying to use gloss to make animations where each "model" step is relatively time expensive. I'm using the IO.Simulate module because my step function needs to do an IO operation which takes around 1 second (it may vary). I will try to give some details. I have the step function: step :: Model -> IO Model step m = do ... p <- slowOperation ... return newModel The rest of the program is small and simple. The drawing function (Model -> IO Picture -- it is pure though) is as quick as simple. However, the program get stuck after the first iteration. In the other hand, I am using the animateIO function which ask me for an Int value to set up "the number of simulation steps to take for each second of real time". But I'm more interested in the animation waiting for the simulation step to end. Does it make sense? I would be really thankful with any pointer here. Thanks in advance, Daniel Díaz. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Gloss and relatively expensive computations
You could create a new thread which would be 'forever' executing your extensive computation and updating some IOVar accordingly. The drawing function would do nothing except reading that IOVar and displaying its contents. Since drawing is cheap, this can be done at any reasonable rate. 28.12.2012 3:22 пользователь "Daniel Díaz Casanueva" написал: > Hello cafe! > > I'm having some performance issues trying to use gloss to make animations > where each "model" step is relatively time expensive. I'm using the > IO.Simulate module because my step function needs to do an IO operation > which takes around 1 second (it may vary). > > I will try to give some details. > > I have the step function: > > step :: Model -> IO Model > step m = do > ... > p <- slowOperation > ... > return newModel > > The rest of the program is small and simple. The drawing function (Model > -> IO Picture -- it is pure though) is as quick as simple. However, the > program get stuck after the first iteration. > > In the other hand, I am using the animateIO function which ask me for an > Int value to set up "the number of simulation steps to take for each second > of real time". But I'm more interested in the animation waiting for the > simulation step to end. Does it make sense? > > I would be really thankful with any pointer here. > > Thanks in advance, > Daniel Díaz. > > ___ > 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] my Fasta is slow ;(
Thank you. Your entry is great. Faster than fortran entry!Dou you want to contribute at the site, or you want me to do it for you? Date: Thu, 27 Dec 2012 15:58:40 -0800 Subject: Re: [Haskell-cafe] my Fasta is slow ;( From: b...@serpentine.com To: bm...@hotmail.com CC: haskell-cafe@haskell.org On Tue, Dec 18, 2012 at 12:42 PM, Branimir Maksimovic wrote: Seems to me that culprit is in function random as I have tested rest of codeand didn't found speed related problems. The problem with your original program was that it was not pure enough. Because you stored your PRNG state in an IORef, you forced the program to allocate and case-inspect boxed Ints in its inner loop. I refactored it slightly to make genRand and genRandom pure, and combined with using the LLVM back end, this doubled the program's performance, so that the Haskell program ran at the same speed as your C++ version. The next bottleneck was that your program was performing floating point arithmetic in the inner loop. I changed it to precompute a small lookup table, followed by only using integer arithmetic in the inner loop (the same technique used by the fastest C fasta program). This further improved performance: the new Haskell code is 40% faster than the C++ program, and only ~20% slower than the C program that currently tops the shootout chart. The Haskell source is a little over half the size of the C source. You can follow the work I did here: https://github.com/bos/shootout-fasta ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Documentation operator
I also like this idea a lot! Here're a couple more benefits: 1) This makes it possible to generate documentation from TH - quite handy for things like lens generation / Yesod-like DSLs. 2) The annotation can aid automatically determining how an API has changed. I have a WIP tool[1] that tries to generate a module signature file that's amenable to line-based-diffing. Having these type annotations could really aid such diffs in being informative. 3) This would interact very well with holes in type signatures (not currently part of GHC holes, IIRC). Not only could you document the holes, but you can also get docs-for-free from the "neat composition trick". There would definitely need to be GHC support - wouldn't want these appearing in type errors! -Michael [1] https://github.com/mgsloan/api-compat/blob/master/examples/template-haskell.api.diff On Thu, Dec 27, 2012 at 1:40 PM, Clark Gaebel wrote: > I love the idea, but it seems like it's a bit too early in Haskell's life > to implement it. Not everyone's on GHC 7.6.1+. > > - Clark > > > On Thu, Dec 27, 2012 at 3:20 PM, Iavor Diatchki > wrote: > >> Hi, >> >> I think that this is a neat idea that should be explored more! GHC's >> parser has a bunch of awkward duplication to handle attaching documentation >> to types, and it'd be cool if we could replace it with an actual language >> construct. >> >> Happy holidays! >> -Iavor >> >> On Wed, Dec 26, 2012 at 3:27 AM, Christopher Done wrote: >> >>> Hello chums, >>> >>> I've been playing around with an idea, something that has obvious pros >>> and cons, but I'll sell it to you because there might be some positive >>> ideas out of it. Consider the following operator: >>> >>> {-# LANGUAGE TypeOperators, DataKinds, KindSignatures #-} >>> >>> module Docs where >>> >>> import GHC.TypeLits >>> >>> type a ? (sym :: Symbol) = a >>> >>> First I'll describe how I'd want to use this and then what I think >>> are the advantages and disadvantages. >>> >>> I call this (?) operator “the documentation operator”, to be used for: >>> >>> * Things that either don't belong or can't be encoded in the type >>> system, or for things need to be in English. >>> * Things that cannot be encoded in Haddock. >>> >>> The simple case of ye olde days: >>> >>> -- | Lorem ipsum dolor sit amet. Suspendisse lacinia nibh et >>> -- leo. Aenean auctor aliquam dapibus. >>> loremIpsum :: Int -> Int -> String >>> >>> Which has since been somewhat evolved into: >>> >>> loremIpsum :: Int-- ^ Lorem ipsum dolor sit amet. >>>-> Int-- ^ Suspendisse lacinia nibh et leo. >>>-> String -- ^ Aenean auctor aliquam dapibus. >>> >>> But could now be written: >>> >>> loremIpsum :: Int? "Lorem ipsum dolor sit amet." >>>-> Int? "Suspendisse lacinia nibh et leo." >>>-> String ? "Aenean auctor aliquam dapibus." >>> >>> Here is a contrived case I'll use later on: >>> >>> data Person = Person >>> >>> describeAge :: Int ? "an age" -> String ? "description of their >>> elderliness" >>> describeAge n = undefined >>> >>> personAge :: Person ? "a person" -> Int ? "their age" >>> personAge = undefined >>> >>> One could also encode previously informal specifications more formally, >>> so that >>> >>> -- | The action 'hFlush' @hdl@ causes any items buffered for output >>> -- in handle @hdl@ to be sent immediately to the operating system. >>> -- >>> -- This operation may fail with: >>> -- >>> -- * 'isFullError' if the device is full; >>> -- >>> -- * 'isPermissionError' if a system resource limit would be >>> exceeded. >>> --It is unspecified whether the characters in the buffer are >>> discarded >>> --or retained under these circumstances. >>> hFlush :: Handle -> IO () >>> hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer >>> >>> with >>> >>> type Throws ex (docs :: Symbol) = docs >>> >>> could now be written >>> >>> hFlush :: Handle ? "flush buffered items for output on this handle" >>> -> IO () >>> ? Throws IsFullError "if the device is full" >>> ? Throws IsPermissionError >>>"if a system resource limit would be exceeded. It is \ >>>\unspecified whether the characters in the buffer are \ >>>\discarded or retained under these circumstances." >>> hFlush handle = wantWritableHandle "hFlush" handle flushWriteBuffer >>> >>> With this in place, in GHCi you get documentation "lookup" for free: >>> >>> > :t hFlush >>> hFlush >>> :: (Handle ? "flush buffered items for output on this handle") >>> -> (IO () ? Throws IsFullError "if the device is full") >>> ? Throws >>> IsPermissionError >>> "if a system resource limit would be exceeded. It is >>> unspecified >>> whether the characters in the buffer are discarded or
Re: [Haskell-cafe] Makefile for a Haskell Project
On Fri, 28 Dec 2012, xuan bach wrote: Hi everyone, I'm a newbie in Haskell. I'm wondering that if there is any tool support creating Makefile for Haskell project like Ocamlbuild for Ocaml project? Since ghc handles dependencies automatically, I usually just do, all: ghc --make myprog And then make sure `myprog.hs` is your Main module. Thank you, Regards. -- *Le Dinh Xuan Bach* *Tel: 01234711869 or +65 86967149 * *Email: pig28...@gmail.com School of Information and Communication, * *Hanoi University of Science and Technology - レ。ディン。スアン。バイック 電話番号:01234711869 or +65 86967149 メール: pig28...@gmail.com * -- Scott Lawrence___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Makefile for a Haskell Project
Hi Scott, Thanks for your kind comment. By the way, is it possible to use ghc --make for my project including some external libraries and tools such as happy, Parsec and haskell stub calling C library? I also tried out cabal to build my project but it seems quite complicated to use. Best Regards. On Fri, Dec 28, 2012 at 2:08 PM, Scott Lawrence wrote: > On Fri, 28 Dec 2012, xuan bach wrote: > > Hi everyone, >> I'm a newbie in Haskell. >> >> I'm wondering that if there is any tool support >> creating Makefile for Haskell project like Ocamlbuild >> for Ocaml project? >> > > Since ghc handles dependencies automatically, I usually just do, > > all: > ghc --make myprog > > And then make sure `myprog.hs` is your Main module. > > >> Thank you, >> Regards. >> >> -- >> *Le Dinh Xuan Bach* >> *Tel: 01234711869 or +65 86967149 >> * >> *Email: pig28...@gmail.com >> >> School of Information and Communication, >> * >> *Hanoi University of Science and Technology >> >> --**--**- >> レ。ディン。スアン。バイック >> 電話番号:01234711869 or +65 86967149 >> メール: pig28...@gmail.com >> * >> >> > -- > Scott Lawrence -- *Le Dinh Xuan Bach* *Tel: 01234711869 or +65 86967149 * *Email: pig28...@gmail.com School of Information and Communication, * *Hanoi University of Science and Technology - レ。ディン。スアン。バイック 電話番号:01234711869 or +65 86967149 メール: pig28...@gmail.com * ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Makefile for a Haskell Project
On Fri, 28 Dec 2012, xuan bach wrote: Hi Scott, Thanks for your kind comment. By the way, is it possible to use ghc --make for my project including some external libraries and tools such as happy, Parsec and haskell stub calling C library? I'm not sure about happy and foreign interfaces - as long as parsec is installed (via cabal or your distribution's packages), GHC will use it correctly. I also tried out cabal to build my project but it seems quite complicated to use. It's worth it if you want a more elaborate build process than ghc itself can accomodate, or if you intend to distribute your software on hackage. Running "cabal init" will guide you through creating a stub cabal file, so it's not too bad. Best Regards. On Fri, Dec 28, 2012 at 2:08 PM, Scott Lawrence wrote: On Fri, 28 Dec 2012, xuan bach wrote: Hi everyone, I'm a newbie in Haskell. I'm wondering that if there is any tool support creating Makefile for Haskell project like Ocamlbuild for Ocaml project? Since ghc handles dependencies automatically, I usually just do, all: ghc --make myprog And then make sure `myprog.hs` is your Main module. Thank you, Regards. -- *Le Dinh Xuan Bach* *Tel: 01234711869 or +65 86967149 * *Email: pig28...@gmail.com School of Information and Communication, * *Hanoi University of Science and Technology --**--**- レ。ディン。スアン。バイック 電話番号:01234711869 or +65 86967149 メール: pig28...@gmail.com * -- Scott Lawrence -- *Le Dinh Xuan Bach* *Tel: 01234711869 or +65 86967149 * *Email: pig28...@gmail.com School of Information and Communication, * *Hanoi University of Science and Technology - レ。ディン。スアン。バイック 電話番号:01234711869 or +65 86967149 メール: pig28...@gmail.com * -- Scott Lawrence___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe