Experimental IRC log haskell-2007-11-24

Available formats: content-negotiated html turtle (see SIOC for the vocabulary)

Back to channel and daily index: content-negotiated html turtle

These logs are provided as an experiment in indexing discussions using IRCHub.py, Irc2RDF.hs, and SIOC.

00:00:39<dons>ddarius: any other keywords i can try?
00:01:53<ddarius>http://www.haskell.org/haskellwiki/Applications_and_libraries/Data_structures There's a Data.Relation on this. I'm not sure what all it does.
00:01:54<lambdabot>Title: Applications and libraries/Data structures - HaskellWiki, http://tinyurl.com/247ycb
00:03:17<ddarius>http://wiki.di.uminho.pt/twiki/bin/view/Personal/Joost/RelationsInHaskell
00:03:18<lambdabot>http://tinyurl.com/2h6jm3
00:03:45<jdrake>Would you guys understand a 'Typing' definition for an integer constant that is like this: G |- Int : int
00:03:55<jdrake>It is part of domtool's language reference, but I understand it not.
00:04:40<ddarius>It seems to say Int has type int in context G
00:04:56<ddarius>But it should tell you what the judgement stands for somewhere.
00:05:40<jdrake>I have never seen |- before.
00:06:20<faxathisia>jdrake: http://mumble.net/~campbell/images/HM-t-shirt.png
00:06:38<conal>faxathisia: lol
00:07:03<jdrake>faxathisia: Might be useful as a shirt :p
00:07:16<faxathisia>jdrake: anyway I would say read TAPL is really nice
00:07:20<faxathisia>em
00:07:33<darinm>there is a shirt with that
00:07:36<faxathisia>Types and Programming Languages http://www.cis.upenn.edu/~bcpierce/tapl/
00:07:36<lambdabot>Title: Types and Programming Languages
00:07:41<jdrake>What is TAPL?
00:07:47<faxathisia>if you're library has it or anything
00:07:48<darinm>Types and Programming Languages
00:08:56<darinm>or if you want something free, you can check Harper's book (draft)
00:08:58<darinm>http://www.cs.cmu.edu/~rwh/plbook/book.pdf
00:09:19<jdrake>I like free :p
00:09:26<jdrake>Although $46.16 isn't bad for it either
00:10:13<darinm>it's worth the money if you're into that stuff
00:10:17<conal>jdrake: or take a simple explanation: G is a collection of name/type pairs, and G |- e : t says that given the typings in G, e can be determined to have type t.
00:11:09<adrian>Does anyone have experience with passing a raw struct (not a pointer to a struct) to a C function via the FFI?
00:11:18<jdrake>oh yes, Int is an integer constant and I guess 'int' is the type.
00:11:21<ddarius>jdrake: Know any logic programming?
00:11:35<jdrake>ddarius: Not particularily
00:11:43<conal>jdrake: yes, and with no restrictions on G
00:12:03<faxathisia>adrian: It's not possible with haskells FFI
00:12:17<jdrake>I would love to be able to program a fully typesafe microcontroller language :p
00:12:22<ddarius>jdrake: By 'not particularly' do you mean 'no'?
00:12:23<conal>jdrake: if you look at the lambda case, you can see how typings get added to G.
00:12:28<faxathisia>adrian: You may learn about the ABI for your system and write appropriate code if it's possible .. or write a glue code wrapping the C function
00:12:31<jdrake>ddarius: yes :p
00:13:05<oerjan>faxathisia: i vaguely recall someone implying that one of the c2hs things handles such matters?
00:13:11<adrian>faxathisia: thanks. that's sort of what I expected but I wanted to confirm
00:13:22<goalieca>@src product
00:13:23<lambdabot>product = foldl (*) 1
00:13:40<conal>jdrake: you can think of those typing rules as a program either to verify that an expression has a type in some context (G) or to compute the type from the context and expression.
00:14:00<conal>jdrake: (a functional program)
00:14:17<davidL>hmm, I am doing a foreign import ccall on this C function: png_read_png(png_ptr, info_ptr, png_transforms, NULL) ... that one of the c2hs things handles such matters?
00:14:28<davidL>err
00:14:43<ddarius>typecheck :: Map Variable Type -> Expression -> Type -> Bool; typecheck G e t = ...
00:14:52<jdrake>I wonder if this core domtool language is capable of being used for generic purposes :p
00:15:19<conal>jdrake: perhaps, but i bet haskell would be more fun. :)
00:15:36<davidL>hmm, I am doing a foreign import ccall on this C function: png_read_png(png_ptr, info_ptr, png_transforms, NULL) ... what should be in place of XXX? f_png_read_png :: Ptr a -> Ptr b -> Int -> XXX
00:16:05<jdrake>conal: Even better- port it to haskell :p
00:16:21<faxathisia>even better write a haskell SML ffi ?? :P
00:16:23<conal>jdrake: as an embedded language.
00:16:40<ddarius>faxathisia: Haskell can talk to SML.
00:16:49<faxathisia>oh how?
00:17:00<ddarius>The FFI
00:17:23<jdrake>conal: If you can imagine a wiki page that has an embedded script to generate a particular graphic, say a vector graphically demonstrating 3+4i, and it generates the image when the wiki page is generated (and caches).
00:17:31<jdrake>That is the sort of thing I would love to have.
00:17:53<faxathisia>the C FFI or is there a SML one?
00:18:03<ddarius>@google Haskell Server Pages
00:18:05<lambdabot>http://www.cs.chalmers.se/~d00nibro/hsp/
00:18:05<lambdabot>Title: HSP - Haskell Server Pages
00:18:57<ddarius>faxathisia: The FFI is not required to be just C, but yes, worst-case scenario I'm sure SML can expose it's functions via a C interface and Haskell can definitely use them.
00:19:00<jdrake>smlweb :p
00:19:03<conal>jdrake: sounds nifty. and yeah, see HSP. also, client-side execution could be cool. then you could do interactive graphics.
00:19:21<faxathisia>I see
00:19:54<jdrake>conal: Not too interested in client side, more interested in backend generating user viewable pages that are not modifiable by the user.
00:25:54<jdrake>Is a 'functor' the same thing as a first class function?
00:25:54<Cale>jdrake: nope
00:25:54<Cale>jdrake: A functor is a type constructor which supports an operation like 'map'
00:25:54<Cale>@src Functor
00:25:54<lambdabot>class Functor f where
00:25:54<lambdabot> fmap :: (a -> b) -> f a -> f b
00:25:54<Cale>So more or less, it's a data structure with homogeneously typed contents which has a way to apply a function to all the elements held inside it.
00:25:54<kpreid>Is there a type which is a container of no values of a particular type, and thus implements Functor as fmap _ = id?
00:25:54<Cale>Well, not id
00:25:54<ddarius>In C++ the term 'functor' -is- used for 'function object' which is a poor man's way of simulating higher order functions.
00:25:54<Cale>because id would never unify in the right way
00:25:54<kpreid>Cale: whoops, right
00:25:54<ddarius>kpreid: newtype Const a = Const
00:25:54<ddarius>er data
00:25:54<kpreid>ddarius: I'm asking if it exists already
00:25:54<ddarius>kpreid: No it doesn't.
00:25:54<kpreid>\x -> x => id is only universally valid in untyped lambda calculus...
00:25:54<kpreid>er, untyped whatever
00:25:54<jdrake>Just to be sure, would it be something like map `+` [1 2 3 4 5] [1 2 3 4 5] (not specifically haskel syntax)
00:25:54<oerjan>newtype Const a b = Const a, surely?
00:25:54<Cale>jdrake: err, what would you expect that to do?
00:25:54<oerjan>and instance Functor (Const a) where fmap = id
00:25:54<oerjan>er no
00:25:54<Toxaris>instance Functor () where fmap = const id
00:25:54<oerjan>fmap (Const x) = Const x
00:25:54<Toxaris>hmm no, you need an * -> * of course :(
00:25:54<faxathisia>jdrake: in haskell it'd be like map (uncurry (+)) $ zip [1..5] [1..5]
00:25:58<Toxaris>so data Const a = Const; instance Functor Const where fmap = const id
00:26:19<ddarius>map (uncurry (+) $ zip .. .. = zipWith (+) .. ..
00:26:21<jdrake>Cale: [1+1 2+2 ...]
00:26:30<jdrake>$ does ?
00:26:44<oerjan>Toxaris: not that either
00:26:55<ddarius>($) = id
00:27:00<ddarius>@src ($)
00:27:00<lambdabot>f $ x = f x
00:27:03<oerjan>the phantom type a prevents it from typechecking
00:27:23<jdrake>ok
00:27:30<ddarius>oerjan: Indeed. That is one of the few cases when an unsafeCoerce might not be unreasonable.
00:28:07<ski>m@(Left _) >>= _ = m -- is a similar case
00:29:04<jdrake>There is a thing I want to implement - a versioning file system - on top of the wiki I envision. Is this sort of thing a reasonable thing to make, maybe using some of darcs?
00:29:14<ski>(s/Left _/Nothing/ is the same)
00:30:43<resiak>jdrake: have you seen ikiwiki?
00:30:57<jdrake>resiak: I have heard of it.
00:31:00<Toxaris>oerjan: hmm yes, after all, it's *not* the same type
00:32:06<oerjan>Toxaris: easy to wrap and unwrap the constructor though
00:32:23<resiak>jdrake: okay, just thought i'd mention it since you're talking about a vcs-wiki synergy
00:32:34<jdrake>resiak: Something like that
00:33:01<jdrake>A friend of mine once asked, why doesn't any modern unix have a versioning file system?
00:33:11<oerjan>Toxaris: actually the newtype Const a b = Const a should work even better, since newtype constructors are eliminated on implementation
00:37:26<newsham>jdrake: darcs, cvs, svn, hg, etc.
00:37:29<newsham>who needs to complicate the fs?
00:37:55<Vq^>isn't there some FUSE driver for svn?
00:39:05<jdrake>newsham: You don't always have everything conveniently saved in a history :p
00:39:45<thoughtpolice>jdrake: dragonflybsd is planning to implement a filesystem with 'versioning' capabilities. i'm running dfly 1.10 but the fs is scheduled for beta at the 2.0 release
00:40:10<newsham>fossil/venti?
00:40:36<thoughtpolice>i believe dillon named it HAMMER or somesuch
00:40:43<thoughtpolice>there was a link to the spec on reddit a while ago
00:40:50<newsham>ZFS supports snapshots
00:41:03<idnar_>snapshots aren't automatic
00:41:09<Cale>jdrake: that would be zipWith
00:41:14<idnar_>of course, filesystems don't really have transactional semantics, so there's already a problem
00:41:17<Cale>> zipWith (+) [1..5] [1..5]
00:41:19<lambdabot> [2,4,6,8,10]
00:41:23<thoughtpolice>yeah. zfs snapshots are pretty nice (ran solaris 10 before i installed fbsd,) but i believe hammer is designed to do this automatically
00:41:29<jdrake>idnar_: ITS had it apparently
00:41:35<mikael>OS X Leopard has like a time machine that lets you fly in time and/or space with real-time 3D effects
00:41:38<P_D>I've got a lot of C structs in memory which I ned to poke and prod at. At the moment I'm using hsc2hs, but I've got a lot of structs with definitions shifting about. I'd like to have just one representation for them in the C header. Is there a way to automatically derive Storable instances or something equivalent?
00:41:51<Cale>The map function just takes a function and applies it to the elements of a single list.
00:42:00<Cale>> map (+1) [1..5]
00:42:01<lambdabot> [2,3,4,5,6]
00:42:02<newsham>if you use a write-only filesystem you have all versions of every file at your disposable
00:42:03<thoughtpolice>newsham: i believe the idea is you just mount a filesystem with an 'at date' and it'll map the drive as it was on that date.
00:42:10<Cale>> map (+) [1..5]
00:42:11<lambdabot> [<Integer -> Integer>,<Integer -> Integer>,<Integer -> Integer>,<Integer -> ...
00:42:11<idnar_>jdrake: eh, well, you know what I mean
00:42:18<thoughtpolice>but I'm not sure exactly how that works
00:42:26<Cale>> zipWith ($) (map (+) [1..5]) [1..5]
00:42:27<lambdabot> [2,4,6,8,10]
00:42:29<thoughtpolice>because the paper made my head spin after like the first paragraph or so
00:42:31<newsham>err.. append-only
00:43:38<P_D>I understand Data.Binary is the modern way to do marshalling, but that seems to be built on bytestrings. I've just got Ptr Structs coming in.
00:43:39<thoughtpolice>newsham: it looks very interesting though. i like dragonfly, so i'll be sure to give it a spin when 2.0 comes out
00:43:43<Toxaris>thinking about functors wich aren't containers, would it make sense to have instance Functor ((->) a) where fmap = (.)?
00:43:44<Vq^>http://wayback.sourceforge.net/ <- FUSE based versioning filesystem
00:43:45<lambdabot>Title: Wayback: User-level Versioning File System for Linux
00:44:22<thoughtpolice>i'm actually compiling nhc on it right now because I want a haskell compiler, but my port of ghc 6.6 didn't go so well a while back. might try 6.8.1 soon
00:44:27<oerjan>> (+) `fmap` 1 `fmap` 1 -- yes
00:44:28<lambdabot> add an instance declaration for (Show (f (a -> a)))
00:44:40<oerjan>um...
00:44:50<oerjan>> ((+) `fmap` 1) `fmap` 1 -- yes
00:44:51<lambdabot> add an instance declaration for (Show (f (a -> a)))
00:44:52<P_D>> (+) 1 `fmap` 1 `fmap` 1
00:44:52<lambdabot> add an instance declaration for (Show (f t))
00:45:02<sizur>how to coerce from Float to Double?
00:45:11<newsham>http://en.wikipedia.org/wiki/Fossil_(file_system)
00:45:11<oerjan>er... messing up
00:45:14<resiak>@hoogle Float -> Double
00:45:15<lambdabot>No matches, try a more general search
00:45:21<P_D>sizur: realToFrac
00:45:26<sizur>thanks
00:45:27<oerjan>> (+1) `fmap` (+1) $ 1
00:45:28<lambdabot> 3
00:45:38<oerjan>Toxaris: ^^
00:45:43<thoughtpolice>newsham: oh, and there's also ext3cow which does something similar for linux: http://www.ext3cow.com
00:45:43<lambdabot>Title: Welcome
00:45:45<P_D>> (realToFrac (1.0 ::Float)) :: Double
00:45:45<lambdabot> 1.0
00:45:53<sizur>yeah it works
00:46:03<thoughtpolice>i've never used it though (I came across it when it was beta,) but it looks neat.
00:46:34<jdrake>Cool wayback :p
00:46:36<thoughtpolice>and i'm pretty sure it's most likely a hell of a lot more efficient than a system built on fuse
00:47:08<thoughtpolice>although zfs-on-fuse apparently gets some pretty decent performance.
00:47:22<Toxaris>oerjan: thanks :) once again, i found what was already there. "you could have invented the Functor instance for (a ->)"
00:48:30<oerjan>Toxaris: remember that every monad is morally an applicative and a functor, although someone could forget to write the instances
00:48:34<jdrake>What is a non-basic haskell tutorial for someone who has looked into haskell before but didn't remember everything?
00:48:47<resiak>isn't there a Monad a => Functor a instance?
00:48:59<oerjan>resiak: no
00:49:05<newsham>jdrake: gentle introduction?
00:49:06<P_D>jdrake: gentle introduction is aimed at people with some experience in FP
00:49:11<resiak>oerjan: hrm, why not?
00:49:12<Toxaris>oerjan: I'm aware of that
00:49:21<oerjan>it would have overlapping problems
00:49:41<P_D>@src seq
00:49:41<lambdabot>Source not found. You type like i drive.
00:49:56<jdrake>perfect
00:49:59<resiak>oerjan: because there are separate Functor instances for Maybe and friends?
00:51:20<oerjan>resiak: as well as things that are Functors but not Monads. for technical reasons if you have instance Monad a => Functor a then only the Functor a part is considered on lookup, so _everything_ would overlap
00:52:38<conal>because instance selection just uses the head, not the context. it doesn't search.
00:52:41<oerjan>the "right" thing would be to make Monad a subclass of Functor
00:53:11<Toxaris>> getConst $ fmap undefined $ Const "just found 'Const' in Control.Applicative"
00:53:12<lambdabot> "just found 'Const' in Control.Applicative"
00:53:23<conal>oerjan: and allow subclasses to provide definitions or defaults for superclass methods.
00:54:04<oerjan>grumble grumble class alias proposal grumble grumble
00:54:09<newsham>class monoidalcategory
00:54:11<resiak>oerjan: ah, i see
00:55:03<jdrake>Has anyone ever explained the value of functional programming to the conservative system administration type that is unconvinced it would survive in a high use environment? I have a friend like this, and his opinion of functional languages is not high due to that background.
00:55:29<jeffz>jdrake: there was a mention of a system administrator programming in Haskell, on programming.reddit.com not long ago
00:55:50<conal>and the Linspire story
00:56:23<newsham>jdrake: my web server is written in haskell.
00:56:43<newsham>i wouldnt say its "high use" but its got lots of uptime and doesnt fall over
00:56:58<jdrake>OMG, there is a lot of useful stuff on there today
00:57:57<mikael>there's this haskell mail server that's really flexible and configurable and whatnot and which looks like a conservative sysadmin type would find cool
00:58:11<jdrake>I can't find the sysadmin link though
00:58:33<SamB_XP>functional programming is not quite orthogonal to whether or not your web server falls over...
00:58:45<SamB_XP>but I don't see how it would make your webserver fall over
00:58:58<mikael>here it is: http://postmaster.cryp.to/
00:58:58<lambdabot>Title: Postmaster ESMTP Server
00:59:10<newsham>sam: if your a sysadmin that thinks that functional programming is not ready for high use
00:59:15<newsham>its a datapoint against that opinion
01:00:16<SamB_XP>wasn't that what you had said was not useful
01:00:41<newsham>hm? what did I say?
01:01:09<JohnMeacham>cinema: pong.
01:01:10<SamB_XP>in any case, a sysadmin should be concerned with particular programs
01:01:17<SamB_XP>should he not?
01:01:17<conal>mikael: neat! configuring a mailserver in haskell. opens up possibilities for elegant mail combinators.
01:01:22<newsham>definitely.
01:01:54<oerjan>instance Monad Postal
01:02:19<conal>monad - urg.
01:02:26<oerjan>instance Arrow then
01:03:00<conal>or Applicative
01:03:16<conal>but preferably with a simple, IO-free semantics.
01:12:17<jdrake>Windows seriously needs a ps decoder
01:12:46<jeffz>jdrake: ps decoder?
01:13:11<jdrake>Something like postscript to pdf
01:13:15<SamB_XP>I have often wondered why Adobe Reader does not perform this function
01:13:17<jeffz>yeah... ghostscript.
01:13:40<jeffz>jdrake: ghostscript has been around for yonks.
01:14:00<mikael>mac's preview converts ps to pdf but usually it makes these huge bitmap pdfs or something that are super slow to scroll through
01:14:21<thoughtpolice>jdrake: i tried using gs's provided ps2pdf.bat file and it broke because of some stupid reason
01:14:32<jeffz>ACTION never has any problem with it.
01:14:36<thoughtpolice>i go the poor man's way: download the ps on linux, use ps2pdf there, and then send the file over using netcat
01:15:48<conal>i use ps2pdf on my windows machine
01:16:07<thoughtpolice>mine normally gives some weird error of "could not open temp file: ''" or somesuch.
01:16:19<thoughtpolice>it's not that big of an inconvenience though, honestly.
01:16:28<jeffz>SamB_XP: Adobe Reader not reading PostScript files is most likely a ploy by Adobe to make sure people don't increase their use of PostScript.
01:16:57<SamB_XP>jeffz: why would Adobe mind this?
01:17:03<jdrake>Well, I have ghostscript, but no ps2pdf.
01:17:12<SamB_XP>Adobe is responsible for BOTH technologies...
01:17:13<jdrake>Ghostscript can show the ps file, but it looks unreadable
01:17:15<conal>i got my ps2pdf with MiKTeX
01:17:16<jeffz>SamB_XP: the way I see it, PDF is more profitable to them
01:17:53<jdrake>I am definitely not downloading miktex
01:19:43<jdrake>of course ps2pdf.com is nice too :p
01:21:41<davidL>> (3 :: CInt) + 2
01:21:43<lambdabot> Not in scope: type constructor or class `CInt'
01:22:43<ddarius>@index CInt
01:22:43<lambdabot>Foreign.C.Types, Foreign.C
01:22:57<ddarius>> 3 :: Foreign.C.CInt
01:22:57<lambdabot> Not in scope: type constructor or class `Foreign.C.CInt'
01:23:11<ddarius>:t 3 :: Foreign.C.CInt
01:23:13<lambdabot>Foreign.C.Types.CInt
01:24:29<oerjan>:t Foreign.C.unsafePerformIO
01:24:30<lambdabot>Not in scope: `Foreign.C.unsafePerformIO'
01:24:47<oerjan>:t Foreign.unsafePerformIO
01:24:48<lambdabot>forall a. IO a -> a
02:07:24<vincenz>@lang es en cotillo
02:07:33<vincenz>@bot
02:07:34<lambdabot>:)
02:08:06<vincenz>@dict es en cotillo
02:08:07<lambdabot>Supported dictionary-lookup commands:
02:08:07<lambdabot> all-dicts devils easton elements foldoc gazetteer hitchcock jargon lojban vera web1913 wn world02
02:08:07<lambdabot>Use "dict-help [cmd...]" for more.
02:08:23<faxathisia>@babel es en cotillo
02:08:23<lambdabot> cotillo
02:08:29<vincenz>thanks
02:08:34<vincenz>that didn't help much
02:12:21<byorgey>vincenz: what, you don't know what a cotillo is?
02:12:27<vincenz>o.O
02:12:28<vincenz>nope
02:12:43<oerjan>@babel es en Parte del martillo u otra herramienta con la que se golpea
02:12:43<lambdabot> Part of the hammer or another tool with which it is struck
02:13:02<vincenz>I've been told it means gossip
02:13:10<byorgey>vincenz: just kidding, me neither =)
02:13:15<oerjan>@babel es en Parte opuesta al filo en algunos instrumentos cortantes:
02:13:15<lambdabot> Part opposed to the edge in some sharp instruments:
02:13:25<vincenz>no
02:13:27<vincenz>este es cocillo
02:13:42<oerjan>(http://www.wordreference.com/definicion/cotillo)
02:13:43<lambdabot>Title: Yahoo!
02:13:56<vincenz>ah, tu utilizas babel en este modo
02:14:02<vincenz>oerjan: I thought you were writing spanish yourself :)
02:14:08<oerjan>nope
02:14:37<byorgey>http://www.spanishdict.com/1AS.cfm?e=cotilleo
02:14:38<lambdabot>Title: SpanishDICT.com - Dictionary of Spanish and English
02:14:45<oerjan>i just found a spanish definition of cotillo so i needed to translate it
02:14:45<byorgey>that says 'cotilleo' means gossip
02:15:10<oerjan>@babel en es gossip
02:15:11<lambdabot> chisme
02:15:23<oerjan>@babel es en cotilleo
02:15:24<lambdabot> cotilleo
02:15:45<byorgey>your @babel proves nothing. nothing!
02:17:09<vincenz>ACTION moves his lips unsynched with his mouth "your @babel is strong, I will beat you, fight!"
02:17:14<oerjan>@babel es en cotillear
02:17:14<lambdabot> to cotillear
02:17:27<oerjan>>_<
02:18:18<oerjan>lips unsynched with mouth? that takes some skill
02:18:26<vincenz>never seen those japanese movies
02:18:33<vincenz>where they put some really heavy american voice
02:18:50<oerjan>now, lips unsynched with _voice_, on the other hand
02:18:53<faxathisia>ACTION got it :p
02:18:58<vincenz>oh llol
02:19:01<vincenz>bleh, late, tired
02:19:04<vincenz>@localtime oerjan
02:19:05<lambdabot>Local time for oerjan is Sat Nov 24 03:19:05 2007
02:51:58<newsham>?check id === id
02:52:00<lambdabot> Not in scope: `==='
04:53:28<elliottt>?bot
04:53:28<lambdabot>:)
04:53:34<elliottt>@source satisfy
04:53:34<lambdabot>satisfy not available
04:53:45<elliottt>@source Text.ParserCombinators.Parsec.Satisfy
04:53:45<lambdabot>Text.ParserCombinators.Parsec.Satisfy not available
04:53:53<elliottt>@source Text.ParserCombinators.Parsec.Char.Satisfy
04:53:53<lambdabot>Text.ParserCombinators.Parsec.Char.Satisfy not available
04:53:56<elliottt>-_-
04:54:02<hpaste> dufflebunk pasted "How to find number of bytes read" at http://hpaste.org/4067
04:54:46<oerjan>satisfy f = tokenPrim (\c -> show [c]) (\pos c cs -> updatePosChar pos c) (\c -> if f c then Just c else Nothing)
04:55:20<dufflebunk>If anyone has used ByteStrings and Binary and knows how to find out how many bytes Binary used up, I'd appreciate it if you could let me in on the secret
04:55:53<oerjan>elliottt: btw @src is the command for single functions but i doubt it has Parsec
04:57:20<dufflebunk>I pasted a small sample program in the link above. I know, it's probably ugly and awkward... but this is new to me.
05:02:58<oerjan>there ought to be a variant of decode that returns the remaining substring, like with ReadS
05:03:53<Cale>dufflebunk: There's a Data.ByteString.length, I'm fairly sure.
05:04:37<Cale>mm, oh, I see what you mean
05:05:48<Cale>runGetState :: Get a -> ByteString -> Int64 -> (a, ByteString, Int64)
05:07:19<Cale>You can apply that to the 'get' for the appropriate type, along with a ByteString and an initial count, and it'll return the parsed stuff, along with the remainder of the ByteString and the updated count
05:07:35<Cale>(which if you started with 0 should be the number of characters read)
05:08:22<Cale>dufflebunk: does that help?
05:13:19<elliottt>oerjan: thanks :)
05:31:03<chessguy>@seen osfameron
05:31:03<lambdabot>osfameron is in #haskell. I last heard osfameron speak 13h 48m 20s ago.
05:31:47<chessguy>'evening haskellers
05:32:10<dobblego>does anyone have a vmware image (linux) with a lambdabot that compiles and runs properly; and you can just change that configuration and recompile without farting about (lambdabot has wasted so much of my time previously)
05:37:41<chessguy>osfameron++ for some interesting blogs lately
05:37:54<chessguy>@tell osfameron
05:37:54<lambdabot>Consider it noted.
05:37:54<chessguy><chessguy> osfameron++ for some interesting blogs lately
05:38:21<ddarius>Slick.
05:42:22<dufflebunk>Cale: I'm not sure... I seek to a point in a file and then create a lazy byte string, so finding out the remainer might not be very efficient
05:43:00<dufflebunk>Ah, the Int64 is the number used, not number left
05:43:06<Cale>dufflebunk: right.
05:44:43<dufflebunk>That might work. Not as handy as decode, but I'll give it a try
05:44:49<conal>i'm looking for the wiki page about type familes that mentions generalized tries. not sure whether it's on the haskell wiki or the ghc wiki. anyknow know?
05:45:40<allbery_b>@go haskell type families generalized tries
05:45:41<lambdabot>http://haskell.org/haskellwiki/GHC/Indexed_types
05:46:34<conal>allbery_b: thanks. don't know why my googling didn't get it.
05:49:27<dufflebunk>Cale: See, this is where I get confused, in order to run that function I need something of type (Get a), but I have no way of making it...
05:49:34<Cale>get
05:49:49<Cale>You just use get. Let type inference handle the rest.
05:50:53<Cale>You could put some other computation in the Get monad there, but get is what decode would have used.
05:51:42<ddarius>@tell osfameron You most likely want the fields of your game state record to be strict.
05:51:42<lambdabot>Consider it noted.
05:55:02<dufflebunk>Cale: Ok, I sort of get it. I'm having trouble though because the get function doesn't seem to take any input... but I guess that's ok if it simply returns a function that does the work.
05:55:16<Cale>dufflebunk: It's polymorphic
05:55:17<ddarius>:t Data.Binary.get
05:55:19<lambdabot>forall t. (Data.Binary.Binary t) => Data.Binary.Get.Get t
05:55:43<Cale>dufflebunk: Its value depends on which instance of Binary is present.
05:56:09<Cale>dufflebunk: See, you defined it for TwoChars just above there.
05:56:21<dufflebunk>Right, but get returns the same thing each time it's called for TwoChars
05:56:34<Cale>right
05:56:44<Cale>It's always the same computation
05:56:51<Cale>(the one which reads two chars)
05:57:20<sclv>?ty plusPtr
05:57:21<lambdabot>Not in scope: `plusPtr'
05:57:37<sclv>?hoogle plusPtr
05:57:37<lambdabot>Foreign.Ptr.plusPtr :: Ptr a -> Int -> Ptr b
05:57:44<Cale>Just like getLine is always the computation which gets a line of text from the user.
05:57:58<Cale>Even though the user might enter different text each time.
05:58:22<dufflebunk>Yeah, it bugs me. I'll get used to it though.
05:58:27<ddarius>:t getLine
05:58:27<lambdabot>IO String
05:58:49<dufflebunk>Cale: Any idea what the third argument is in runGetState ?
05:59:33<oerjan>:t Data.Binary.Get.runGetState
05:59:34<lambdabot>forall a. Data.Binary.Get.Get a -> Data.ByteString.Lazy.ByteString -> Int64 -> (a, Data.ByteString.Lazy.ByteString, Int64)
05:59:36<Cale>dufflebunk: The initial Int64 that it starts counting from
05:59:43<Cale>So in your case, I think you want 0
05:59:46<ddarius>State passing
06:00:22<oerjan>ah right, runGetState is the run for the Get monad
06:00:46<ass_lover>any news of a haskell operating system?
06:01:11<Cale>There is one or two. I'd advise you to change your nick.
06:01:12<dobblego>@where house
06:01:13<lambdabot>http://www.cse.ogi.edu/~hallgren/House/
06:03:36<ass_lover>any professional programmers here?
06:03:49<math_lover>:)
06:08:20<hpaste> dufflebunk annotated "How to find number of bytes read" with "Working" at http://hpaste.org/4067#a1
06:08:59<dufflebunk>Cale: Thanks, that seems to work
06:09:11<Cale>great :)
06:09:39<Cale>s/subtype/instance/
06:09:48<Cale>(Binary isn't a type)
06:11:03<math_lover>typage
06:11:16<dufflebunk>What is it if it's not a type?
06:11:26<ddarius>A new thesis to read (if I haven't already... which is likely [that I have])
06:11:44<oerjan>a type class
06:11:45<ddarius>dufflebunk: An instance
06:12:01<ddarius>Er Binary is a type class and TwoChars is an instance of it.
06:12:01<Cale>dufflebunk: A typeclass, yes
06:12:14<ddarius>type class /= OO class
06:12:37<ddarius>It means something closer to it's usage in set theory. I.e. a collection of things.
06:12:41<dufflebunk>Ah, right. I keep forgetting there's a whole new level
06:13:03<Cale>I tend to think of typeclasses as relations on types.
06:13:14<math_lover>what a large haskell powered website?
06:13:17<Cale>Many of which are just unary relations, so either true or false.
06:13:33<Cale>math_lover: how large?
06:14:27<math_lover>couple 1000 users
06:14:32<math_lover>stuff liek that
06:14:47<ddarius>ACTION wonders if "third generation wavelets" would return hits'
06:15:02<Cale>http://hackage.haskell.org/packages/hackage.html -- I'm pretty sure this is written in Haskell.
06:15:04<lambdabot>Title: HackageDB: introduction
06:15:07<math_lover>the generation term is so overused in computng lingo
06:15:43<oerjan>generation X-ray?
06:15:46<dufflebunk>ACTION believes that lingo is second generation terminology
06:16:43<ddarius>oerjan: A movie starring Jamie Foxx?
06:17:22<Cale>There was also an online clothing store which was written in Haskell, iirc.
06:17:28<math_lover>hacakge
06:17:29<math_lover>cabal
06:17:30<Cale>I can't recall the url.
06:17:34<math_lover>woa cult liek names
06:17:56<math_lover>"oh our software is 5 generations ahead"
06:18:02<math_lover>----from a bad interview
06:18:20<math_lover>a rabin python fan I might add
06:18:54<agnokapathetic>> let isTriNum n = n == i*(i+1)/ 2 where i = truncate (sqrt (2*n))
06:18:54<lambdabot> Parse error at end of input
06:19:19<agnokapathetic>>let isTriNum n = n == i*(i+1)/ 2 where i = truncate (sqrt (2*n))
06:19:36<agnokapathetic>> let isTriNum n = n == i*(i+1)/ 2 where i = truncate (sqrt (2*n))
06:19:36<lambdabot> Parse error at end of input
06:19:50<dobblego>> let isTriNum n = n == i*(i+1)/ 2 where i = truncate (sqrt (2*n)) in isTriNum 7
06:19:52<lambdabot> Add a type signature
06:20:01<agnokapathetic>oh there we go :-)
06:20:18<Cale>math_lover: You might be interested in http://happs.org/ -- I'm not sure who the users of it are.
06:20:18<lambdabot>Title: HAppS - The Haskell Application Server
06:20:19<agnokapathetic>theres my problem, i keep getting "No instance for (RealFrac Int)"
06:20:34<mlh>http://braintreehemp.com.au/
06:20:43<math_lover>so what is a nice way to learn haskell, and what are the best reasons to learn it when compares to say perl?
06:20:52<dobblego>?type \n -> n == i*(i+1)/ 2 where i = truncate (sqrt (2*n))
06:20:53<lambdabot>parse error on input `where'
06:21:16<ddarius>math_lover: If you are happy with the languages you are currently using, why bother with Haskell?
06:21:17<dobblego>?type \n -> let i = truncate (sqrt (2*n)) in n == i*(i+1)/ 2
06:21:18<lambdabot>forall b. (Floating b, RealFrac b, Integral b) => b -> Bool
06:21:19<agnokapathetic>math_lover: it makes you learn to think in a new way about programming
06:21:28<math_lover>Im not happy only knowing bash
06:21:38<math_lover>http://www.youtube.com/watch?v=zEzh10_xoqw&feature=related
06:21:38<lambdabot>Title: YouTube - barbie girl - aqua
06:21:39<ddarius>math_lover: Why not?
06:22:23<Cale>math_lover: If you're a math person, chances are you'll like Haskell.
06:22:40<oerjan>> let isTriNum n = n == i*(i+1)`div` 2 where i = truncate (sqrt (2*fromIntegral n)) in isTriNum 7
06:22:42<lambdabot> False
06:22:56<agnokapathetic>thank you oerjan :-)
06:23:01<dufflebunk>math_lover: bash is fun
06:23:24<Cale>I wrote an entire IRC bot as essentially a single bash pipeline.
06:23:25<agnokapathetic>bourne shell (similar to bash) server pages: http://hyperrealm.com/wtfd00d/shsp/
06:23:26<lambdabot>Title: Bourne Shell Server Pages
06:23:47<Cale>(with a fifo tying the ends together)
06:23:58<math_lover>pipe is a nice thingy
06:24:06<math_lover>I love cut cron pipe and find
06:24:21<math_lover>alogn with tokenizing greps it makes me feel godlink
06:24:25<math_lover>god-like
06:26:18<oerjan>> filter ("ha" `isInfixOf`) . sort . words $ "haskell has pipes too, sort of"
06:26:19<lambdabot> ["has","haskell"]
06:28:11<math_lover>I wish my sorcery to become stronger
06:28:40<Cale>Haskell is a pretty fun language.
06:29:14<Cale>It's by far my favourite of the 15 or 20 programming languages I know reasonably well.
06:30:53<ddarius>Cale: You ever read the papers on TyPiCal?
06:31:51<Cale>Hmm, the name rings a bell, but I don't think I have.
06:32:11<tits_loover>k
06:32:20<tits_loover>hello?
06:32:22<ddarius>Paul Snively often mentioned it on LtU. I just recently decided to actually look at it.
06:32:26<Cale>...yeah, that's not an appropriate nick here.
06:32:38<tits_loover>Im trying to change
06:32:46<tits_loover>mirc not doing what I want
06:32:56<Cale>I recommend X-Chat.
06:33:06<math_guy88>crap
06:33:07<math_guy88>ok
06:33:19<math_guy88>so wait
06:33:20<math_guy88>cale
06:33:25<Cale>ddarius: Is there a more googleable phrase?
06:33:27<math_guy88>why haskell your favorite?
06:34:32<Cale>math_guy88: Because it makes it much easier to write programs that actually work the first time. Code is easier to think about than in most languages since it tends to satisfy lots of nice properties and guarantees.
06:34:46<math_guy88>ah
06:34:47<ddarius>Cale: The key is to add "pi calculus". But anyway, here is the page: http://www.kb.ecei.tohoku.ac.jp/~koba/typical/
06:34:48<lambdabot>Title: TyPiCal
06:34:53<Cale>It's also rather compact. 3 lines of Haskell code can do quite a lot.
06:34:56<math_guy88>what haskell programs have you made lately?
06:35:29<ddarius>"A New Type System for Deadlock-Free Processes" This paper is the one I'm looking at now. http://www.kb.ecei.tohoku.ac.jp/~koba/papers/concur2006-full.pdf)
06:35:36<Cale>I've been working on a binding to Imlib 2, but mostly small things lately.
06:36:21<Cale>The largest Haskell program I've written was a pipeline scheduler for PPC+Altivec assembly code.
06:36:38<math_guy88>oow what does it do?
06:36:50<Cale>It was about 1200 lines of code, about half of which was documentation, and it would have been something like 15000 lines of C code.
06:37:01<math_guy88>I am messing with forth common lisp perl tcl and haskell
06:37:26<math_guy88>1200
06:37:30<Cale>It reordered the instructions in programs so that different parts of the processor could work at the same time more effectively.
06:37:33<math_guy88>vs 15000 is huge reducation
06:37:45<math_guy88>is that GOOD c code like reusing subroutines etc.?
06:37:59<Cale>yes
06:38:06<math_guy88>wow
06:38:08<Cale>That's an estimate by an expert C programmer.
06:38:20<math_guy88>thats a lot less 1 to 4th vs 1 to 3rd
06:38:31<math_guy88>wow
06:38:50<math_guy88>ddi you make sue of haskell libs?
06:38:58<math_guy88>to cheat ro is it head to head comparison/
06:39:34<Cale>I didn't really use that much in the way of libraries.
06:39:42<dobblego>Haskell libraries are pure, which makes them easy to compose
06:39:46<Cale>I just made really good use of lazy evaluation.
06:40:04<Cale>and monads
06:40:18<Cale>(particularly there was quite a lot of the list monad)
06:40:31<ddarius>ACTION wonders if a constraint logic language wouldn't have been better still.
06:40:37<Cale>Well, possibly, yes.
06:40:53<Cale>That's essentially what the problem was.
06:41:13<wli>Constraint logic languages are something I'd like to know more about.
06:42:11<Olathe>calvins: Is the code for that scheduler available ?
06:42:15<Olathe>Cale
06:43:08<dfranke>is there a way to get deriving to work on GADTs?
06:43:16<ddarius>Hack GHC?
06:43:24<Cale>Olathe: No, unfortunately. When I left, it stayed with my supervisor at McMaster. I don't know if that code is going to end up in anything released or not.
06:43:43<Olathe>Ahh, OK.
06:43:57<dufflebunk>My brother went to McMaster
06:43:58<Cale>Olathe: I won't be too surprised if they find a better algorithm than I came up with for doing that.
06:44:19<Cale>I'm actually a Waterloo person, I just worked at McMaster for a Summer.
06:47:06<atp>hey guys. if i have a type which depends on some parameter, in the way Maybe a depends on a (i'm not sure what the proper term for that is called), is it possible to make that type forall a an instance of some class?
06:47:29<oerjan>atp: sure
06:47:33<atp>how?
06:47:35<Cale>math_guy88: I mostly use Haskell for small mathematical experiments. These days I think way more about the structure of programs than actually writing code.
06:47:40<dobblego>?kind Maybe
06:47:41<lambdabot>* -> *
06:47:46<dobblego>?kind Maybe Int
06:47:47<lambdabot>*
06:47:51<Olathe>@help kind
06:47:52<lambdabot>kind <type>. Return the kind of a type
06:48:10<Cale>atp: instance Foo (T a) where ...
06:48:10<Olathe>Returns the car of an automobile.
06:48:43<atp>see, i tried that, and it complains about a kind mismatch. could it be that my definition of the class is wrong?
06:48:55<Cale>atp: Oh, perhaps you want
06:48:59<Cale>instance Foo T where
06:49:09<Cale>It depends on which class it is.
06:49:29<atp>well, it's a class i defined myself, and at the moment it looks like this: class Container a where ...
06:49:32<Cale>Classes are allowed to have type constructors for parameters.
06:49:38<Cale>okay
06:49:51<atp>basically the deal is this, a is most likely a type that looks like say, Object a
06:49:57<Cale>and so 'a' there is a variable representing a type constructor?
06:50:00<atp>or lets call it something other than a
06:50:03<atp>Object o
06:50:17<atp>and the functions in the Container a class don't really care what o is specifically
06:50:27<oerjan>data Object o = ... ?
06:50:30<Cale>all right
06:50:36<dfranke>well, so much for SYB making things easier if I'm going to have to manually derive Data.
06:50:45<Cale>Let me see a type signature for one of the functions in that class Container
06:50:56<atp>oerjan: it's a big datastructure... the o is mainly there because that allows it to be a recursive datatype in some instances where that's convenient...
06:51:04<Cale>(specifically, one which uses the type variable a)
06:51:35<atp>ok, i have one that looks like addContained :: a -> o -> Maybe a
06:51:45<Cale>for any a?
06:52:02<oerjan>is this a multiparameter type class?
06:52:05<Cale>There's basically only two things such a function could be doing
06:52:10<oerjan>Container o a ?
06:52:10<atp>oh i see wait wait
06:52:12<atp>right
06:52:15<Cale>addContained x y = Just x
06:52:17<Cale>or
06:52:19<Cale>addContained x y = Nothing
06:52:27<atp>I should be saying a o -> o -> Maybe (a o) huh
06:52:36<Cale>yeah
06:52:38<atp>duh
06:52:41<Cale>that's more likely :)
06:52:44<atp>sorry, that was a major brain fart
06:52:51<atp>thanks for helping me think straight
06:52:56<Cale>no problem
06:52:56<atp>you too oerjan
06:53:24<oerjan>ok, then it ought to be instance Container Foo where
06:54:08<oerjan>since a gets kind * -> *
06:55:05<atp>yeah
07:01:01<atp>ok, another type question
07:01:43<atp>suppose i have a class that looks like this: class Foo a where getString :: a -> String
07:01:57<atp>now, I have my earlier data structure, Object o
07:02:05<atp>now regardless of what the o in Object o is,
07:02:16<atp>i want to define getString on it
07:02:24<atp>and make it an instance of my Foo class
07:02:26<atp>forall o
07:02:42<atp>can i do something like instance Foo (Object o) where ... ?
07:02:59<oerjan>sure
07:04:10<atp>hm...
07:04:21<oerjan>although with no restriction on o you won't be able to make the string depend on it
07:04:31<atp>the string doesn't depend on it
07:04:35<atp>that's why i'm asking
07:04:48<oerjan>(btw the class Show is similar to Foo)
07:04:59<atp>that's a good point
07:05:09<Brian```>@src Reader
07:05:10<lambdabot>Source not found.
07:05:21<atp>but doesn't show require that the a also be an instance of Show?
07:05:54<oerjan>not if you write the instance yourself
07:05:58<Cale>atp: usually, since you usually want to show the elements too
07:06:02<oerjan>only for deriving
07:06:06<atp>ah, i see
07:06:36<oerjan>newtype Reader r a = Reader { runReader :: r -> a }
07:06:46<oerjan>Brian```: ^^
07:08:22<oerjan>incidentally, lambdabot has just such Show instances for some of the types it won't "run":
07:08:37<oerjan>> print "test"
07:08:39<lambdabot> <IO ()>
07:08:42<Cale>> getLine
07:08:43<lambdabot> <IO [Char]>
07:09:00<Cale>> reverse
07:09:00<lambdabot> Add a type signature
07:09:11<Cale>> [reverse]
07:09:11<lambdabot> Add a type signature
07:09:14<Cale>hmm :)
07:09:16<Olathe>> reverse::[[]]
07:09:17<lambdabot> `[]' is not applied to enough type arguments
07:09:17<lambdabot> Expected kind `*', but ...
07:09:24<Cale>oh, it's polymorphic, right
07:09:27<Olathe>> reverse [[], []]
07:09:28<lambdabot> [[],[]]
07:09:38<Olathe>> reverse::[[a]]
07:09:38<oerjan>> chr
07:09:39<lambdabot> Couldn't match expected type `[[a]]'
07:09:39<lambdabot> <Int -> Char>
07:09:41<Cale>> [reverse :: String -> String]
07:09:41<lambdabot> [<[Char] -> [Char]>]
07:09:51<Cale>:)
07:09:54<Olathe>> reverse::[[reverse]]
07:09:54<lambdabot> Couldn't match expected type `[[reverse]]'
07:10:01<Olathe>> reverse::[[reverse::[Int]]]
07:10:02<lambdabot> Parse error at "::[In..." (column 19)
07:10:21<brad_>anyone have a decent summary of what i can and can't do with nhc98 vs ghc?
07:10:22<Olathe>> reverse::[[<[Int]->[Int]>]]
07:10:23<lambdabot> Parse error at "<[Int..." (column 12)
07:10:25<oerjan>although actually those instances require a Typeable instance to give the type, i guess
07:11:07<Olathe>> reverse [reverse, tail]
07:11:09<lambdabot> Add a type signature
07:11:09<oerjan>but they don't use the actual value, only the type
07:11:29<Olathe>> [reverse, tail]
07:11:37<Olathe>:(
07:11:38<lambdabot> Add a type signature
07:11:55<oerjan>Olathe: i think only some specific types have such instances (IO, ->)
07:12:19<oerjan>because otherwise you would get overlapping with the ordinary ones
07:13:00<oerjan>and [] already has a Prelude Show instance
07:13:26<ddarius>oerjan: What's your point?
07:13:28<oerjan>hm, wait...
07:13:37<oerjan>that _should_ use the one for the functions
07:13:59<oerjan>> [map chr, map chr . reverse]
07:14:01<lambdabot> [<[Int] -> [Char]>,<[Int] -> [Char]>]
07:14:20<atp>thanks for the help guys, i'm out
07:15:16<oerjan>ddarius: i was thinking if lambdabot used a generic overlapping Show based on Typeable, then you could imagine it printing <[[Int] -> [Char]]> there
07:16:14<ddarius>oerjan: Ah.
07:16:34<oerjan>> print "a" >> return [map chr, map chr . reverse] -- adding an IO should work
07:16:36<lambdabot> <IO [[Int] -> [Char]]>
07:22:21<luqui>is there a way to specify constraints on an associated type
07:23:01<luqui>say, class VectorSpace v where type Field v :: *, I want to make sure Field v is an instance of Num
07:26:39<luqui>where by "type" I mean "data"
07:26:56<luqui>oh wait
07:27:02<luqui>can associated types even do that?
07:28:08<luqui>ah, got it, class (Num (Field v)) => VectorSpace v where ...
08:18:51<sorear>math_guy88: what's the difference between you and math_lover?
08:19:05<math_guy88>a few letters
08:19:18<math_guy88>this mirc client is hellish
08:34:31<roconnor>@type join map
08:34:34<lambdabot> Couldn't match expected type `a -> b' against inferred type `[a]'
08:34:34<lambdabot> Expected type: (a -> b) -> (a -> b) -> a1
08:34:34<lambdabot> Inferred type: (a -> b) -> [a] -> [b]
08:34:38<roconnor>@type join . map
08:34:39<lambdabot> Couldn't match expected type `(->) [a]' against inferred type `[]'
08:34:39<lambdabot> Probable cause: `map' is applied to too many arguments
08:34:39<lambdabot> In the second argument of `(.)', namely `map'
08:34:46<roconnor>@type (join .) . map
08:34:47<lambdabot>forall a a1. (a1 -> [a]) -> [a1] -> [a]
08:34:54<goalieca>lol. i love lazyness. i forgot to actually display the results so it didn't compute them :P
08:34:59<goalieca>saved me a good half-hour :P
08:35:29<roconnor>@type =<<
08:35:31<lambdabot>parse error on input `=<<'
08:35:35<roconnor>@type (=<<)
08:35:36<lambdabot>forall a (m :: * -> *) b. (Monad m) => (a -> m b) -> m a -> m b
08:36:19<sclv>?hoogle pokeByteOff
08:36:20<lambdabot>Foreign.Storable.pokeByteOff :: Storable a => Ptr b -> Int -> a -> IO ()
09:33:06<wli>I wonder if there's something I'm missing wrt. GADT's.
09:33:51<wli>The use cases don't seem very obvious to me.
09:37:31<integral>hmm, does haskell have the "parallel-or" operator?
09:37:44<wli>No.
09:37:52<wli>integral: Wanting full abstraction, are you?
09:37:58<integral>I was just wondering :-)
09:38:37<integral>ACTION hasn't quite got a handle yet on how different languages differ yet
09:49:31<hpaste> toad3k pasted "used to calculate likelihood of certain coin toss patterns" at http://hpaste.org/4068
10:03:44<wli>ACTION wonders if Cayenne questions would be too far off topic.
10:06:11<quicksilver>wli: I doubt people will mind, but I certainly won't know the answers :)
10:06:39<wli>quicksilver: Linear algebra with dependent types is too sexy to pass up.
10:07:48<quicksilver>;)
10:08:50<wli>quicksilver: First I need to figure out how to define Galois fields...
10:10:24<wli>quicksilver: At the very least a proper numeric hierarchy should be easier to implement. ;)
10:13:52<math_guy88>galois fields, ok I feel dumb, what are they?
10:14:26<dobblego>it's a farm, owned by Galois, where they grow the lambda crop, in large fields
10:14:47<wli>math_guy88: Finite fields. The first associated with a prime p is Z/pZ, then they're the splitting fields of x^(p^n)-x over that or some such.
10:15:40<wli>math_guy88: GF(p^n) is a field with p^n elements for a prime p and a natural number n > 0.
10:17:21<wli>math_guy88: You need dependent types to ensure the modulus of Z/pZ is prime in the types indexed by natural numbers.
10:17:55<math_guy88>wow
10:18:06<wli>math_guy88: Z/pZ being "Z mod p Z" or the integers modulo the prime p.
10:18:16<mlesniak>Does Haskell support escape sequences? I'd like to clear the screen using putStrLn "\027[2J;", but it does not work under ghci
10:18:26<wli>mlesniak: Yes.
10:18:30<quicksilver>that's not haskell's problem, mlesniak
10:18:36<quicksilver>that's all down to whatever terminal you're using
10:18:52<mlesniak>quicksilver: thought, the cmd-shell from windows supports them?
10:19:02<dmead>if it did
10:19:04<dmead>i'd be suprised
10:19:17<mlesniak>:-/ Ok, I see, thanks :)
10:19:21<wli>mlesniak: Trying to do vt100 escape codes?
10:19:22<quicksilver>no idea :)
10:19:33<math_guy88>when you say modulo
10:19:44<math_guy88>do you mean absolute value?
10:20:03<mlesniak>wli: I'm not sure from which standard it is, but the \escape[2J; thing worked for me till I have to use windows ;-)
10:20:35<math_guy88>'clear' on a linux box clears the screen....
10:20:35<wli>mlesniak: Maybe you mean \033
10:20:53<allbery_b>vt100-derived / ansi escapes commonly work in unixy terminal emulators, but are not supported in windows console mode
10:21:10<mlesniak>wli: Hmm, possibly ;)
10:21:18<mlesniak>allbery_b: that's a pity :-/
10:21:42<mlesniak>ACTION is used to unix terminals...
10:21:54<allbery_b>http://en.wikipedia.org/wiki/ANSI_escape_code
10:21:54<lambdabot>Title: ANSI escape code - Wikipedia, the free encyclopedia
10:21:55<wli>mlesniak: Try putStr "\^[[2J;"
10:22:45<Liskni_si>(i'd leave out the semicolon and add a move to (0,0), but that's not going to make it work in windows, of course)
10:23:01<mlesniak>Liskni_si: This would be the 2nd step
10:23:28<wli>mlesniak: Hmm, Windows is another story entirely. Different command set there.
10:24:10<mlesniak>wli: It *should* work according to wikipedia, but I have to load ANSI.sys, that just f*ck_ng stupid!
10:24:33<mlesniak>ACTION is not even sure if he has to reboot to use config.sys ;)
10:24:34<wli>mlesniak: You're basically writing a low-level terminal driver.
10:24:56<wli>mlesniak: You're issuing a clear screen command, which is different for different terminal types.
10:25:11<allbery_b>read again, only 16-bit VDMs will do that
10:25:15<allbery_b>32-bit programs won't
10:25:45<hpaste> (anonymous) annotated "used to calculate likelihood of certain coin toss patterns" with "(no title)" at http://hpaste.org/4068#a1
10:25:46<mlesniak>wli: I don't plan to use the "whole" terminal stuff ,just want to clear the screen for convience ;)
10:27:50<wli>mlesniak: What you're doing will break on the wrong terminal types. You're seeing that happening now with Windows. You need to detect the terminal type and figure out the character sequence to issue for a clear screen command from that.
10:28:28<wli>mlesniak: There are probably ncurses bindings sufficient for your purposes but I've no idea how they play with Windows.
10:29:02<mlesniak>wli: I see, but I think that's becoming to much work for just having a small cls-function which is not "really" needed
10:29:12<mlesniak>anyway, it's not a haskell problem but a windows one
10:29:39<mlesniak>wli: but thanks for the suggestions :)
10:29:41<wli>mlesniak: You shouldn't have to write it yourself. Just find the ncurses lib and call it and drag in ncurses on Windows.
10:30:24<mlesniak>wli: that's also good idea, thanks
10:30:50<allbery_b>on unix you can just capture the output of "tput clear", or for a one-shot just run it directly
10:31:16<allbery_b>or even just running "clear" (and on windows try "cls")
10:33:02<SnailRacer>It's not haskell's fault, but it is still it's problem *sigh*
10:37:47<wli>I started on a pure Haskell NIH of ncurses.
10:38:07<wli>I don't have the wherewithal or intestinal fortitude to finish it.
10:40:19<wli>FFI calls to ncurses don't fly because of the signal handling behavior of FFI calls.
10:43:52<allbery_b>@where hscurses
10:43:52<lambdabot>http://www.informatik.uni-freiburg.de/~wehr/haskell/
10:44:42<firefly>is there a "cmmcolour" just like there is an hscolour?
10:45:12<firefly>it would be nice to have some sort of syntax colouring/highlighting for C--
10:47:02<wli>allbery_b: That's an FFI binding IIRC, with all the aforementioned signal handling issues.
10:47:15<wli>allbery_b: (FFI calls blocking signals)
10:47:27<allbery_b>yeh
10:47:54<allbery_b>there's vty, but no windows support afaik (and assumes ANSI)
10:48:12<allbery_b>...although these days I would not waste time on something that isn't based on ANSI X3.64
10:48:32<wli>I've got most or all of terminfo parsing/etc. done.
10:48:53<wli>I'm down to basically the idiot interpreter for the escape sequences.
10:49:13<allbery_b>shouldn't be that hard
10:49:53<allbery_b>I've done it in C more times than I can count (before screen became available on various odd platforms)
10:50:26<wli>allbery_b: At my level of burnout everything is hard.
10:51:19<wli>allbery_b: http://holomorphy.com/~wli/hncurses/
10:51:20<lambdabot>Title: Index of /~wli/hncurses
10:53:05<wli>allbery_b: You may be a better candidate to hammer the lib out.
10:53:42<allbery_b>once I'm not constantly tired, maybe. (get to try to schedule blood tests next week, weeee)
10:54:26<wli>allbery_b: You're looking at something on the order of years if you're going to wait for me to do it, so you've got plenty of time.
10:56:09<allbery_b>hm, actually, I'd say you're doing this wrong. use FFI to terminfo to get the escape sequences, implement the rest in haskell
10:56:36<allbery_b>that's a one-time thing at the start of the program
10:57:14<allbery_b>(unless you want to drop to terminfo to translate sgr= or something, but that's a fairly fast call so I'd not worry about signals)
10:58:28<wli>allbery_b: IIRC the escape sequences are not entirely static.
10:59:01<allbery_b>right, that was what I was referring to
10:59:32<allbery_b>thing is, you can drop into FFI to do that and return the string, without to omuch impact on signal handling
10:59:56<phlpp>hi
11:00:14<Lycurgus>hello
11:00:25<allbery_b>although I'd say tputs and tparm are not that difficult in haskell, so you can let the FFI terminfo binding do the rest
11:01:28<Lycurgus>how long have you been programming allbery_b?
11:01:30<wli>allbery_b: I've mostly not even started reading about how runtime usage works. I'm very loath to rely on the FFI but maybe that's just a bad decision.
11:02:05<allbery_b>it's a bad decision for the ncurses input stuff, I;'d think not so bad for output
11:02:25<allbery_b>but, well, I think most programs that use (n)curses ignore the input stuff anyway
11:02:33<allbery_b>it's always been wonky and unreliable
11:02:43<Stinger_>anyone have some good videos of haskell tutes/lectures? or screencasts etc
11:02:51<dobblego>?where video
11:02:51<lambdabot>http://haskell.org/haskellwiki/Video_presentations
11:02:57<dobblego>Stinger_ ^
11:03:03<Stinger_>easy :) thanks
11:03:31<allbery_b>and I *really* would not want to reimplement curses' window handling!
11:03:52<allbery_b>Lycurgus: sorry I missed your question. 1978 or thenabouts :)
11:04:57<allbery_b>ncurses took years to get it right, and original curses has bugs in corner cases (some of them relatively common) that have never been fixed
11:05:05<wli>allbery_b: The plot is mostly centered around constructing a readline equivalent in native Haskell vs. windowing.
11:05:06<Stinger_>heh damn, theres a series of interesting looking vids linked to on that page that are unfortunately in german
11:05:32<dobblego>Stinger_, what kind of video are you after specifically?
11:05:53<Lycurgus>isn't there already an hcurses or sumthin?
11:05:58<allbery_b>ah. so do FFI bindings to terminfo for output. input is unfortunately going to be interesting no matter what
11:06:12<allbery_b>yes, I pointed out hscurses (and vty) earlier
11:06:38<wli>allbery_b: There are other nasties about ncurses which are more general than Haskell esp. in the API but anyway.
11:06:42<Stinger_>well an intro to the monad libraries would be ideal, but the one I was refering to was on generic programming
11:07:14<dobblego>I don't know about a video on generic programming, but there might be one there
11:07:23<wli>allbery_b: Input is my primary concern. Windowing I don't care about much if at all.
11:07:38<Stinger_>yeah I'll keep looking through em
11:09:05<wli>allbery_b: Actually an editbox windowing widget would be nice but it drags in the rest of the windowing system (which is basically crap).
11:10:04<allbery_b>honestly? go look at vty
11:10:06<wli>allbery_b: The state management is fatally flawed to the point you're stuck spawning tty IO slave processes to work around it.
11:10:16<math_guy90>doh
11:11:07<wli>allbery_b: I did and saw it was inadequate in the input department and also not portable across terminal types and so became inspired to do whatever I did.
11:11:29<quicksilver>harsh words from ndm about nhc...
11:12:23<allbery_b>sour grapes froma competitor? (ndm is behind yhc, isn't he?)
11:12:29<wli>allbery_b: (Yes, processes, not threads. You need copies of memory because the data structures are global.)
11:12:42<quicksilver>he uses it, and he's at york
11:12:59<quicksilver>he's not 'behind' it AFAIK
11:13:05<allbery_b>what benighted place are you at that still uses non-ANSI terminals?
11:14:15<wli>allbery_b: There are still plenty of uses for non-ANSI terminals, like line printer consoles, Braille consoles, and so on.
11:21:16<wli>ACTION is really liking Cayenne.
11:33:23<Heffalump>wli: and only on Thursday I was being told Cayenne had failed :-)
11:35:11<wli>Heffalump: Oh dear. Where do I go for dependent types, then?
11:35:42<wli>ACTION will probably end up being the lone user.
11:36:22<wli>Heffalump: There is something to be said for avoiding success. ;)
11:37:52<wli>ACTION thinks about numeric hierarchies and fraction-free Gaussian elimination over Z[5^(1/2)] to distract himself from his utter failure to get X working after a week straight.
11:38:47<Heffalump>I don't think it's failed, per se, but I doubt it has many users or much/any development.
11:39:26<wli>Dependent types mean I can get a numeric hierarchy that doesn't suck.
11:41:39<wli>I just need to get a bit further than hello world.
11:46:42<Heffalump>anyone familiar with building GHC? In particular is there a way to build a 32-bit i386 version on a 64-bit machine?
11:47:21<wli>AIUI cross-builds are difficult somehow.
11:48:01<wli>I've had my own biarch difficulties.
11:50:32<abell>Heffalump, if you are on Linux, I would chroot into a 32-bit environment and work from there
11:51:40<wli>I was trying to build a ghc targetting x86-64 on an x86-32 -mostly userspace on an x86-64 box.
11:52:07<wli>It did not go smoothly.
11:55:07<hpaste> (anonymous) annotated "used to calculate likelihood of certain coin toss patterns" with "(no title)" at http://hpaste.org/4068#a2
11:55:31<Heffalump>abell: ok, I was hoping to avoid doing that :-)
11:56:20<Heffalump>actually, I'm not sure what my userspace is, now I come to think of it...
11:56:33<Heffalump>there must be an obvious way to check (Debian)
11:56:58<wli>file `which file`
11:57:07<Heffalump>cunning :-)
11:57:18<Heffalump>ok, so it's a 32-bit userspace, but GHC's configure still seems to decide on 64 bit.
11:57:31<wli>It goes by the uname of the machine.
11:57:46<Heffalump>right. Is it just a question of passing it a few flags and everything else will work out?
11:57:51<hpaste> (anonymous) annotated "used to calculate likelihood of certain coin toss patterns" with "(no title)" at http://hpaste.org/4068#a3
11:57:58<wli>There's an environment trick or two and a few fixups beyond that in the code where that gets bypassed.
11:59:34<Heffalump>ugh
11:59:37<wli>linux32 is the first trick, the second is to export CC="gcc -m32" or similar because gcc itself is insane and insists on incompatibility by always generating 64-bit code unless specifically directed.
11:59:45<Heffalump>surely the GHC developers must have to do this a lot?
12:00:11<wli>Leave off the "in" in let
12:00:40<Heffalump>what do you mean by 'linux32'?
12:00:48<wli>/usr/bin/linux32
12:01:14<Heffalump>ACTION installs it
12:01:20<wli>I think it tries to use an LD_PRELOAD to intercept uname syscalls.
12:01:40<wli>It's in linux32 on Debian.
12:01:52<Heffalump>indeed, I've got it and am configuring now
12:02:18<wli>Anyway, whenever the environment gets blown away these things stop working.
12:03:15<wli>And that happens, so you'll see build failures and 64-bit ELF files floating around. Where that happened I went in and added crap to makefiles or edited source to remove things activated by 64-bit defines.
12:03:41<hkBst>> let hy x = PutStr "hello" >> x in hy 3
12:03:43<lambdabot> Not in scope: data constructor `PutStr'
12:03:59<wli>Lowercase putStr
12:04:32<wli>Identifiers starting with capital letters are special things like types and constructors (trust us, this helps).
12:04:55<phlpp>> let hy x = putStr "foo " >> 3 in hy 3
12:04:56<lambdabot> add an instance declaration for (Num (IO b))
12:04:56<lambdabot> In the expression: let hy ...
12:05:25<phlpp>> let hy x = putStr "foo " ++ putStr 3 in hy 3
12:05:26<lambdabot> Couldn't match expected type `[a]' against inferred type `IO ()'
12:05:38<phlpp>> let hy x = putStr "foo " >> show x in hy 3
12:05:38<lambdabot> Couldn't match expected type `IO' against inferred type `[]'
12:05:53<phlpp>> let hy x = putStr "foo " >> putStr x in hy 3
12:05:53<lambdabot> add an instance declaration for (Num String)
12:05:57<wli>let hy x = putStrLn $ "foo " ++ show x in hy 3
12:06:05<phlpp>boo!
12:08:35<Heffalump>I guess I could just reboot onto a 32-bit kernel...
12:08:48<hkBst>let hy x = putStr "hello" >> x in (hy 3) (liftM +) (hy 2)
12:08:53<hkBst>> let hy x = putStr "hello" >> x in (hy 3) (liftM +) (hy 2)
12:08:54<lambdabot> Couldn't match expected type `t1 -> t2 -> t'
12:10:06<wli>:t let hy x = putStr "hello " >> return x in liftM2 (+) (hy 3) (hy 2)
12:10:10<lambdabot>forall a1. (Num a1) => IO a1
12:10:51<hkBst>> let hy x = putStr "hello" >> x in (liftM2 (+)) (hy 3) (hy 2)
12:10:54<lambdabot> add an instance declaration for (Num (IO b))
12:11:19<wli>You need return x
12:12:01<hkBst>wli: isn't there some trick to make return implicit?
12:12:51<hkBst>> let hy x = do{putStr "hello"; x} in (liftM2 (+)) (hy 3) (hy 2)
12:13:03<lambdabot> add an instance declaration for (Num (IO a1))
12:13:18<sjanssen>hkBst: no
12:13:21<wli>hkBst: No implicit return, sorry.
12:13:54<wli>hkBst: We don't want you to forget you're in a monad.
12:15:44<hkBst>how do I make ghci recognize liftM2 ?
12:15:55<wli>Do :m + Control.Monad
12:16:55<wli>let hy x = putStr "hello " >> return x in liftM2 (+) (hy 3) (hy 2) :: IO Int
12:17:03<wli>That works in ghci with no warnings for me.
12:17:36<hkBst>wli: it works now :)
12:18:11<hkBst>> let hy x y = putStr x >> return y in liftM2 (+) (hy "a" 1) (hy "b" 2)
12:18:17<wli>hkBst: I use -Wall in ghci to warn me when types are defaulted.
12:18:25<lambdabot> <IO Integer>
12:18:45<hkBst>wli: defaulted?
12:19:12<wli>hkBst: 1 could be an Int or an Integer or a Double or a Rational.
12:19:49<wli>hkBst: If there's not enough information to decide, the default behavior of the compiler is to silently choose one for you.
12:19:56<wli>hkBst: I prefer to be warned.
12:21:26<hkBst>in that expression above, is it garuanteed that b prints after a?
12:21:45<wli>> (read $ show 5) + 1
12:22:00<lambdabot> 6
12:22:04<wli>hkBst: That's a good example of defaulting gone wild.
12:22:11<wli>:t (read $ show 5) + 1
12:22:12<lambdabot>forall a. (Read a, Num a) => a
12:22:34<wli>hkBst: Yes, it's guaranteed that b prints after a.
12:22:41<Armor_Azrael>Hey, can someone tell me how to make an instance that operates something like:
12:22:41<Armor_Azrael>instance Eq (a -> b)
12:22:41<Armor_Azrael> a == b = False
12:23:05<Armor_Azrael>Basically, I know function equality is hard, and have a data structure that sometimes has function attributes, and want it to be able to derive eq
12:23:12<Armor_Azrael>ideas?
12:24:25<hkBst>wli: I don't understand what's gone wild.
12:25:49<hkBst>ML seems to like to default types though :)
12:26:01<Armor_Azrael>err, my bad, I figured it out
12:26:10<Armor_Azrael>I just needed another nesting of parens, sorry
12:27:47<hkBst>the order of evaluating function arguments depends on the function definition, right?
12:28:50<desegnis>hkBst: It even depends on the function definition whether function arguments are evaluated at all. So I guess the answer is yes.
12:29:44<hkBst>:src liftM2
12:29:46<desegnis>hkBst: Note, though, that Haskell implementations do not guarantee any specific evaluation order. They only guarantee to deliver the right result.
12:29:57<bakert>If I have something in a monad and I want to move it into IO monad - am I relying on the creator of the monad to have provided a Monad x -> IO x type function? Or is there a more general way to achieve that?
12:30:16<hkBst>@src liftM2
12:30:16<lambdabot>liftM2 f m1 m2 = do { x1 <- m1; x2 <- m2; return (f x1 x2) }
12:30:22<bakert>(I actually just want to print something that is in Gen (from QuickCheck))
12:30:56<desegnis>bakert: The Monad must incorporate IO somehow. There is a MonadIO class that gives you liftIO.
12:31:20<bakert>thanks
12:32:07<hkBst>@src liftM6
12:32:07<lambdabot>Source not found.
12:32:42<bakert>:t Test.QuickCheck.generate
12:32:48<lambdabot>forall a. Int -> StdGen -> Gen a -> a
12:33:03<desegnis>I think the idea of liftIO is that any monad transformer simply passes it through to the underlying monad, so even if using nested monad transformers, it will finally reach IO.
12:35:08<desegnis>I don't see any IO in Gen, though, so you might have to fall back to using trace
12:38:08<wli>Sorry, nature called.
12:38:31<wli>hkBst: How are things going over there?
12:39:24<hkBst>wli: I need to practice my Monads and read up :)
12:39:28<wli>http://holomorphy.com/~wli/LiftedIO.hs
12:40:12<wli>hkBst: I found springschool95.ps (also .pdf) and YAHT to be the two monad things that got me off the ground.
12:41:18<hkBst>http://web.cecs.pdx.edu/~mpj/pubs/springschool95.pdf
12:41:41<hkBst>thanks wli
12:41:45<wli>hkBst: That's the first of the two. YAHT is hosted on haskell.org now AIUI.
12:42:01<wli>hkBst: Beware that springschool95.pdf uses antiquated notation.
12:43:18<wli>hkBst: The big enlightening example was the join operation on AST's (or otherwise variable substitution).
12:45:21<wli>%format return \eta
12:45:54<wli>ACTION found it annoying that standard IO bits weren't lifted in the first place, and so wrote LiftedIO.hs
12:47:19<hkBst>wli: standard IO bits as in string operations?
12:47:45<mauke>?
12:47:58<wli>hkBst: outputting strings to handles, inputting strings from handles, etc.
12:48:59<wli>hkBst: This only matters when you've got monad transformer stacks in play.
12:49:41<hkBst>wli: hehe :) I'll not worry about it then
12:51:12<Mitar>how can I convert an Int to Char (ASCII)?
12:51:19<Heffalump>@type chr
12:51:21<lambdabot>Int -> Char
12:51:24<wli>hkBst: A lot of times people want to "escape" the IO monad. That's the wrong way. You use monad transformer stacks and it looks "inside out" there and you can freely mix IO with the other monads given lifting like I've done in LiftedIO or lifting various other IO subroutines you may have defined for yourself. Then when you force the monad transformer stack you unravel it all.
12:52:03<Mitar>not in scope?
12:52:18<Mitar>Data.Char :-)
12:52:19<Mitar>thanks
12:52:33<wli>hkBst: I'd not even try to get around without monad transformers and the MTL (Monad Transformer Library).
13:44:13<bakert_>Is there any haskell wiki software? I suppose I mean written in haskell or particularly haskell-friendly? What does haskell.org use?
13:45:34<bakert_>it's some earlier or customized version of MediaWiki by the looks of things
13:49:39<mauke>MediaWiki 1.5.4
13:52:25<bakert_>hmm ... thinks about writing the 9 millionth implementation of wiki ...
13:57:03<sannysanoff>@quite ghc API
13:57:03<lambdabot>Maybe you meant: quit quote
13:57:08<sannysanoff>@quote ghc API
13:57:08<lambdabot>No quotes match. Sorry about this, I know it's a bit silly.
14:10:23<vwx>hello
14:10:57<pmatos>Hello all, I know there is a way to do this but I can't remember the syntax to strictly evaluate a function in haskell.
14:11:02<pmatos>Anyone?
14:11:23<mauke>what do you mean by that?
14:11:49<Zao>$! maybe?
14:11:51<pmatos>mauke: ok, basically I have a function which returns a list and I want to tell ghc to compute the whole list, not just the first element.
14:12:14<desegnis>pmatos: You can force the order of evalution using seq , or you may annotate a field of a data constructor to be strict.
14:12:29<mauke>(length x `seq` x)
14:12:51<desegnis>pmatos: The whole list, does that include all its elements, too?
14:13:02<pmatos>yeah, but guess that the function is called f. I want to compute the difference between calling head $ f and the strict evaluation of f.
14:13:24<vwx>how can i sort a list of strings case insensitively?
14:13:28<pmatos>Basically I want to make sure that my function is really doing lazy evaluation on f.
14:13:28<pmatos>heh
14:13:48<mauke>sortBy (\x y -> lc x `compare` lc y) strings
14:13:52<mauke>where lc = map toLower
14:13:54<pmatos>desegnis: yes, i guess so.
14:14:37<pmatos>desegnis: f returns a list of numbers so in a sense I want to ask GHC to compile all the list as if for printing it but without printing (I don't want to know about the time it takes to print)
14:15:16<mauke>show xs `seq` ()
14:15:17<desegnis>pmatos: Then mauke's solution would not be enough for you. You'd need something like foldr seq result xs
14:15:21<pmatos>the problem of calling length of f is that it'll include the time of length which although is probably only linear on the size of the list, might be a lot.
14:15:43<mauke>uh, getting the length is effectively O(1) there
14:15:49<desegnis>(Oh, I'm always thinking ina too complicated way.)
14:15:58<mauke>you already get linearity from forcing the whole thing
14:15:58<pmatos>mauke: why?
14:16:14<mauke>keeping a counter on top of that shouldn't cost much
14:16:20<pmatos>ok...
14:16:45<bakert_>?hoogle getArgs
14:16:46<lambdabot>System.getArgs :: IO [String]
14:16:49<pmatos>is there any function to time a function execution. Some other languages have something called time. Is there such a thing in haskell?
14:17:21<allbery_b>@go site:haskell.org timing computations
14:17:26<faxathisia>there is always, time ./haskellprogram
14:17:27<desegnis>pmatos: If you _just_ want to make sure that f does not consume the whole list, just do f (xs ++ undefined).
14:17:28<lambdabot>http://www.haskell.org/haskellwiki/Timing_computations
14:17:28<lambdabot>Title: Timing computations - HaskellWiki
14:18:08<allbery_b>you *really* want to read that, there are many pitfalls
14:18:43<pmatos>desegnis: what if undefined? will that throw exception when evaluated?
14:18:47<mauke>which language uses "time" for timings?
14:18:49<pmatos>allbery_b: thx
14:19:04<pmatos>mauke: scheme at least . you can do (time (function x))
14:19:05<faxathisia>bash & common lisp
14:19:05<pmatos>for example
14:19:12<mauke>ah
14:19:15<faxathisia>as well
14:19:17<mauke>lisp weirdos
14:19:21<desegnis>pmatos: Yes. It's only useful if you really want a weird error condition :)
14:19:23<pmatos>mauke: lol
14:19:31<pmatos>desegnis: greaT1
14:20:01<sannysanoff>hello all, I am using GHC API to parse haskell code (and get parser tree), but "load" produces '.o' files, which I do not need. How to stop it after parsing phase?
14:20:02<desegnis>pmatos: Of course, you have error "bla", too
14:21:04<sannysanoff>... i am reading through the GHC code for last 2 hours, but nothing works... (ghci debugger is not an option ;-)
14:21:06<pmatos>desegnis: right... I keep forgetting that haskell is lazy and I can do that sort of stuff.
14:21:07<pmatos>heh
14:24:06<pmatos>mauke: I'm trying for example: show xs ++ undefined `seq` () but this doesn't throw undefined, so I would guess it doesn't compute the whole list?
14:24:34<pmatos>well, in fact is show (xs ++ undefined) `seq` ()
14:24:42<pmatos>but still, I get () and that's it.
14:26:27<nornagon>> let xs = [] in show (xs ++ undefined) `seq` ()
14:26:29<lambdabot> Undefined
14:27:35<allbery_b>> let xs = [1] in show (xs ++ undefined) `seq` ()
14:27:36<lambdabot> ()
14:27:49<nornagon>oh right.
14:28:23<pmatos>so I would guess that xs is not evaluated at all, right?
14:28:28<desegnis>The problem is that show returns a lazy string.
14:28:37<pmatos>oh...
14:28:40<pmatos>:-\
14:28:40<allbery_b>> let xs = [1] in (xs ++ undefined) `seq` ()
14:28:42<desegnis>(I think)
14:28:44<nornagon>> let xs = [1] in (show xs ++ undefined) `seq` ()
14:28:44<lambdabot> ()
14:28:44<lambdabot> ()
14:28:50<nornagon>huh
14:29:40<faxathisia>> (reverse $ reverse $ ([1,2,3]++undefined)) `seq` ()
14:29:42<lambdabot> Undefined
14:29:51<faxathisia>> (show $ reverse $ reverse $ ([1,2,3]++undefined)) `seq` ()
14:29:51<lambdabot> Undefined
14:30:00<faxathisia>> (([1,2,3]++undefined)) `seq` ()
14:30:00<lambdabot> ()
14:30:05<faxathisia>> (show $ ([1,2,3]++undefined)) `seq` ()
14:30:06<lambdabot> ()
14:30:43<desegnis>Since lists (and thus, strings) are defined inductively, a list on the left of a `seq` will only have the first (:) of the list evaluated.
14:30:51<allbery_b>does seq only reify xs, and not the spine of the list contained?
14:30:53<nornagon>> ([undefined]) `seq` ()
14:30:53<allbery_b>ah
14:30:53<lambdabot> ()
14:31:17<faxathisia>@pl \f->f this doesnt make any sense
14:31:17<lambdabot>flip (flip (flip (flip ($ this) doesnt) make) any) sense
14:31:31<idnar>heh
14:31:31<allbery_b>that's fine, it only reifies the list, not the first element
14:31:46<allbery_b>@pl \f->f
14:31:46<lambdabot>id
14:32:02<idnar>:t undefined
14:32:03<lambdabot>forall a. a
14:32:29<faxathisia>:t let __ = __ in __
14:32:29<lambdabot>forall t. t
14:32:38<desegnis>allbery_b: More precisely, it only reifies the first cons cell of the list
14:32:56<allbery_b>yeh
14:34:07<desegnis>> let reify xs = foldr seq xs xs in reify ([1,2,3] ++ undefined)
14:34:09<lambdabot> Undefined
14:34:58<wli>ACTION fails to code his way out of a wet paper bag in Cayenne.
14:35:31<allbery_b>even that nly does the cons cells and not their contents, right?
14:35:47<allbery_b>> let reify xs = foldr seq xs xs in reify ([1,2,3,undefined])
14:35:48<lambdabot> Undefined
14:35:50<allbery_b>hm
14:36:07<allbery_b>oh, right. n/m
14:36:30<allbery_b>inserting more pointers than exist :)
14:36:52<desegnis>Still:
14:37:24<desegnis>> let reify_ xs = foldr seq () xs in reify [[1,2],[3,undefined]]
14:37:26<lambdabot> Not in scope: `reify'
14:37:30<desegnis>er
14:37:36<desegnis>> let reify_ xs = foldr seq () xs in reify_ [[1,2],[3,undefined]]
14:37:37<lambdabot> ()
14:37:49<desegnis>obviously...
14:38:08<allbery_b>yeh
14:44:45<pmatos>thanks guys... It'll definitely take me some time to understand what's going on but I'll get there. :-) heh.
14:45:17<pmatos>Anyway, I bought The Haskell Road to Logic Maths and Programming, what would be the next one???
14:48:49<allbery_b>just to amuse yourself, explain the result of let reify xs = foldr seq xs xs in reify [[1,2],[3,undefined]] in ghci
14:50:13<allbery_b>(lambdabot won't work for this)
14:50:46<desegnis>pmatos: A “Real World Haskell” book has been announced for... maybe next year, and it looks promising
14:51:24<fnord123>!where logs
14:51:42<fnord123>(its in the topic, hurr)
14:51:44<nominolo>javascript++
14:51:56<nominolo>@karma javascript
14:51:56<lambdabot>javascript has a karma of 1
14:52:06<nominolo>@karma java
14:52:06<lambdabot>java has a karma of -22
14:52:11<mjrosenb>i join #haskell, and the first thing i see is javascript++ :(
14:52:15<fnord123>@haskell erlang
14:52:15<lambdabot>Unknown command, try @list
14:52:17<desegnis>allbery_b: Lambdabot responses with “thread killed”? Amusing.
14:52:23<faxathisia>javascript++
14:52:24<fnord123>@karma erlang
14:52:24<lambdabot>erlang has a karma of 0
14:52:35<allbery_b>ACTION wa sjust thinking LB needs the same hack it has for java karma
14:52:36<nominolo>mjrosenb: we are (I am) open-minded
14:52:43<allbery_b>hm, it produced Undefined for me
14:52:55<allbery_b>but ghci does something a little different
14:53:09<faxathisia>in javascript you can write a program which lets you click on an image to get a list of coordinates in 2 lines of code :)
14:53:09<mjrosenb>ACTION wants to test the @karma of lots of fun stuffs now
14:53:14<faxathisia>this is a *good thing*
14:53:16<allbery_b><allbery_b> > let reify = join (foldr seq) in reify [[1,2],[3,undefined]]
14:53:16<allbery_b><lambdabot> Undefined
14:53:17<chessguy>mjrosenb, what do you have against javascript?
14:53:33<allbery_b>ACTION admits to cheating there :)
14:53:58<allbery_b>hm, suppose the chet might affect the result
14:54:00<nominolo>faxathisia: javascript is very nice for what it is intended
14:54:01<mjrosenb>chessguy: it's fine as long as i don't have to touch it
14:54:02<desegnis>allbery_b: Now it produces Undefined for me, too. Seems the bot hung for a second. Ah, lambdabot handles undefined differently from ghci...
14:54:04<fnord123>pmatos, I found Haskell School of Expression to be pretty good.
14:54:13<allbery_b>right
14:54:13<nominolo>yahooooo: especially with jQuery
14:54:15<chessguy>js is quite an interesting language
14:54:21<mjrosenb>chessguy: and as long as it doesn't blow up in my face
14:54:34<mjrosenb>right, so does anyone know if haskell supports or patterns?
14:54:47<faxathisia>mjrosenb: What would that be?
14:54:56<nominolo>er ... i meant faxathisia
14:55:28<mjrosenb>faxathisia: you know sml?
14:55:40<faxathisia>mjrosenb: only really basics
14:55:46<mjrosenb>http://rafb.net/p/q0nBgC10.html
14:55:46<lambdabot>Title: Nopaste - No description
14:56:15<mjrosenb>faxathisia: that's an example .. it's something that's planned for the next version of sml
14:56:16<geocalc>@karma--
14:56:17<lambdabot>usage @karma(+|-) nick
14:56:25<allbery_b>mjrosenb: actually there is some excuse for javascript: yhc can compile a subset of haskell to javascript
14:56:25<faxathisia>mjrosenb: so does it match either
14:56:48<mjrosenb>faxathisia: basically. . and it binds x in both cases
14:57:05<faxathisia>mjrosenb: is it equivalent to this http://rafb.net/p/7PAzXP87.txt
14:57:06<vwx>allbery_b: do you a lot about yhc javascript target?
14:57:19<nominolo>mjrosenb: that seems of very limited use
14:57:20<allbery_b>not a whole lot, I just know it's there
14:57:21<paczesiowa>hi, could someone confirm this bug: http://hpaste.org/4069 ?
14:57:30<mjrosenb>faxathisia: yes, but with less code
14:57:31<nominolo>mjrosenb: x has to be the same type in both
14:57:35<allbery_b>something was posted to haskell-cafe recently about the current status and some examples
14:57:47<vwx>allbery_b: yeah, i read that. very cool stuff
14:57:56<mjrosenb>nominolo: you'd be surpriesed, and yes
14:58:05<faxathisia>mjrosenb: no I don't there is any way to do this in haskell
14:58:52<faxathisia>mjrosenb: of course you can do extractOne (y, NONE) = extractOne (NONE, y)
14:58:59<faxathisia>if you decide on some canonical ordering
14:59:15<faxathisia>(cause I'm guessing = x would be something a lot longer..)
14:59:32<faxathisia>mjrosenb: or you can define both cases and use f x ... later on where f x =
15:00:01<mjrosenb>allbery_b: just because you can compile something useful to a given language doesn't mean the target language is useful
15:00:07<nominolo>mjrosenb: what are better uses of this?
15:00:18<mjrosenb>nominolo: RB trees
15:00:27<mjrosenb>nominolo: general syntatic sugar
15:00:28<faxathisia>> let f x = x*x in case (Just 5) of Just x -> f x ; Nothing -> f 0
15:00:40<lambdabot> 25
15:00:41<faxathisia>> case (Just 5) of Just x -> f x ; Nothing -> f 0 where f x = x*x
15:00:41<lambdabot> Not in scope: `f'
15:00:43<faxathisia>hmf
15:00:47<faxathisia>well they should be equivalent
15:01:06<faxathisia>mjrosenb: anyway I'd use where in that casd
15:02:18<nominolo>ACTION goes back to javascript coding ..
15:02:35<mjrosenb>hrmmm
15:02:41<mjrosenb>@karma prolog
15:02:41<lambdabot>prolog has a karma of -1
15:02:44<mjrosenb>:(
15:03:20<mjrosenb>what's the default value for something?
15:03:27<nominolo>@karma
15:03:28<lambdabot>You have a karma of 0
15:03:33<nominolo>that is
15:03:41<mjrosenb>oic
15:04:10<paczesiowa>mjrosenb: do you like prolog? then check whether this prolog parser gives you segfaults http://hpaste.org/4069
15:04:14<faxathisia>@quote prolog
15:04:14<lambdabot>BillWood says: it became obvious that when a Prolog program is tuned by removing non-determinism it moves towards a functional program.
15:04:17<mjrosenb>@karma i_hope_nobodys_changed_the_karma_of_this
15:04:17<lambdabot>i_hope_nobodys_changed_the_karma_of_this has a karma of 0
15:04:23<faxathisia>paczesiowa: writing a prolog?
15:04:26<mjrosenb>i_hope_nobodys_changed_the_karma_of_this++
15:04:38<faxathisia>paczesiowa: ahh nice
15:04:41<firefly>I asked about "sparks" yesterday and they are described in the article "Automatic Spark Strategies and Granularity for a Parallel Functional Language Reducer", Kevin Hammond, Jim S. Mattson Jr, and Simon L. Peyton Jones.
15:04:47<ZsoL>@karma
15:04:48<lambdabot>You have a karma of 0
15:05:09<paczesiowa>faxathisia: yes, but that code was first try. right now I'm finishing prolog lexer (ISO draft compliant:P)
15:05:24<faxathisia>paczesiowa: I wrote an ISO lexer and parser with Parsec for prolog
15:05:31<faxathisia>paczesiowa: but I broke my HD and lost everything >:|
15:05:53<ZsoL>that just happened to me, too
15:06:28<ZsoL>now I'm on a raid1 array :D
15:06:59<allbery_b><3 backups
15:07:08<paczesiowa>wouldn't happen if you shared that code:> I couldn't google anything non-trivial for prolog in haskell
15:07:32<mjrosenb>paczesiowa: prolog.hs:40:9: The last statement in a 'do' construct must be an expression
15:09:06<mjrosenb>paczesiowa: what the deuce is "<|>"?
15:09:16<allbery_b>parsec alternation
15:09:35<paczesiowa>I hate hpaste, it alters tabs
15:09:41<allbery_b>the parser a <|> b attempts to parse a, and if it fails attempts to parse b instead
15:09:48<mjrosenb>paczesiowa: yeah, sounds about right
15:09:48<paczesiowa>wait I'll switch tabs to 8 spaces
15:09:50<allbery_b>tabs are evil
15:10:02<faxathisia>tabs are fine just not in source code :p
15:10:03<paczesiowa>I like them
15:10:13<mjrosenb>okee, so i'm going to move that all onto one line
15:10:21<allbery_b>(more to the point, tabs are inconsistent. typically 8 n unix and 4 or 5 on windows)
15:11:17<sieni>tabs are just fine in source code. just use them properly
15:11:23<hpaste> Paczesiowa annotated "ghc-6.8.1 segfaults" with "tab-free version" at http://hpaste.org/4069#a2
15:11:34<sieni>if your editor fubars your haskell source code, you are using the wrong editor
15:12:14<paczesiowa>mjrosenb: try it now
15:12:45<faxathisia>paczesiowa: well main gave me Struct "john" [Numb 1] in GHC 6.6.1
15:12:56<paczesiowa>faxathisia: I know, problem is with 6.8.1
15:13:10<mjrosenb>paczesiowa: i think there's something fubared with my ghc install
15:13:13<faxathisia>ah sorry.. I wasn't able to compile 6.8.1 yet
15:13:22<mjrosenb>prolog.hs:3:0: Failed to load interface for `Text.ParserCombinators.Parsec'
15:13:57<paczesiowa>if you have 6.8.1 you must install parsec library (it's not anymore in ghc itself)
15:14:12<paczesiowa>unless you use windows
15:14:23<faxathisia>paczesiowa: I think the best thing to do is just make this segfaulting code as minimal as posssible
15:14:24<mjrosenb>oh, hey, that's a package in the overlay
15:14:37<faxathisia>so it is easier to determine/fax what exactly is wrong
15:14:49<faxathisia>fix * :/
15:15:21<mjrosenb>there are a bunch of things in the regex library that don't compile correctly with 6.8.1
15:15:40<paczesiowa>you don't need regex
15:15:44<desegnis>paczesiowa, mjrosenb: Parsec is in the extralibs tarball.
15:15:57<paczesiowa>we use gentoo apparently:P
15:16:09<mjrosenb>paczesiowa: yes indeed
15:16:25<mjrosenb>prolog.o: In function `s10b_info':
15:16:25<mjrosenb>(.text+0x172): undefined reference to `parseczm2zi1zi0zi0_TextziParserCombinatorsziParsecziChar_oneOf_closure'
15:16:29<paczesiowa>so "emerge dev-haskell/parsec" is all we need
15:16:36<mjrosenb>lots and lots of those
15:16:47<paczesiowa>mjrosenb: compile it with "--make" or "package parsec"
15:16:48<desegnis>D'oh :)
15:17:15<paczesiowa>mjrosenb: I wrote those commands in comments at the bottom of src
15:17:21<mjrosenb>ACTION needs to learn how to use haskell's package system
15:17:37<mjrosenb>paczesiowa: mjrosenb@guide2 ~/projects/test $ ./prolog
15:17:37<mjrosenb>Struct "john" [Numb 1]
15:17:59<paczesiowa>faxathisia: I tried doing that, I can't simplify it more (previous versions didn't segfault) besides check my comments at hpaste, it segfaults with ghci and ghc -e but not with ghc itself
15:18:10<bjorkintosh>how similar is haskell to erlang?
15:18:22<bjorkintosh>... on a one to ten scale.
15:18:23<paczesiowa>mjrosenb: did you compile with ghc? try ghci or ghc -e
15:18:34<mjrosenb>let me try with -e
15:18:39<vwx>bjorkintosh: not similar
15:18:48<bjorkintosh>okay thanks.
15:18:54<paczesiowa>ghc Segfault.hs -e "main" -Wall -Werror
15:19:09<bjorkintosh>so i shouldn't pay 55 bucks for that one haskell book i saw then.
15:19:39<mjrosenb>mjrosenb@guide2 ~/projects/test $ ghc prolog.hs --make -e "main" -Wall -Werror
15:19:39<mjrosenb>Struct "john" [Numb 1]
15:19:48<paczesiowa>don't pay for haskell books, there's plenty of free haskell knowledge
15:20:16<allbery_b>mjrosenb: --make is implied for ghci or ghc -e, fwiw
15:20:25<bjorkintosh>hmm
15:20:40<mjrosenb>allbery_b: thanks
15:20:43<allbery_b>(there's a bug registered to make it the default for regular ghc for consistency)
15:20:43<paczesiowa>mjrosenb: --make and -e doesn't work (it just compiles, doesn't run it with -e)
15:20:50<allbery_b>ah
15:20:52<hpaste> mlesniak pasted "Beginner question: Good approach for passing config options?" at http://hpaste.org/4070
15:21:17<daniel_larsson>bjorkintosh: They're both functional languages, but otherwise there are lots of differences. Haskell is statically typed, Erlang dynamically, etc.
15:21:21<mlesniak>ACTION wasn't able to figure out a better title ;)
15:21:58<mjrosenb>dynamically typed functional language??? :(
15:22:11<mauke>scheme?
15:22:30<mjrosenb>mauke: never really like scheme
15:22:34<mjrosenb>same reason
15:23:29<faxathisia>so strange people hating certain types of programming language so strongly :p
15:24:02<bjorkintosh>faxathisia, it's a religious matter and cannot be questioned nor commented on.
15:24:06<mjrosenb>faxathisia: that's because they were created by satan
15:24:31<mauke>where satan = Alonzo Church?
15:24:40<mjrosenb>i mean just look at malbolge
15:24:48<vwx>does erlang have any major advantages over haskell? apart from the automatic distributed feature, which probably wouldn't be too hard to implement in haskell anyway?
15:25:07<paczesiowa>mjrosenb: is it segfaulting yet?:P
15:25:08<resiak>some people love the bitfield syntax
15:25:17<mjrosenb>paczesiowa: nope. . .
15:25:18<ricky_clarkson>Yes, it's dynamically typed.
15:25:48<paczesiowa>mjrosenb: how do you run it?
15:26:01<mjrosenb>paczesiowa: i ran ghc with the command that you gave me, and it ran succussefuly
15:26:25<mjrosenb>paczesiowa: mjrosenb@guide2 ~/projects/test $ ghc prolog.hs --make -e "main" -Wall -Werror
15:26:29<mjrosenb>Struct "john" [Numb 1]
15:28:24<paczesiowa>mjrosenb: when you compiled it with --make earlier there are still working binaries. delete prolog.o prolog.hi and a.out and run again ghc prolog.hs -e "main" -Wall -Werror
15:29:11<allbery_b>segfauted here (6.9.20071025 PPC-G4)
15:29:12<mjrosenb>paczesiowa: yep. . .segfaults now
15:29:41<paczesiowa>so, off to file a bug report (my first:D)
15:30:03<bjorkintosh>aloha.
15:32:06<mjrosenb>paczesiowa: oh yeah, this is on amd64
15:32:41<wli>Nice, a Prolog interpreter.
15:32:58<hpaste> allbery_b annotated "ghc-6.8.1 segfaults" with "backtrace" at http://hpaste.org/4069#a3
15:33:42<paczesiowa>allbery_b: how do I get that backtrace?
15:33:59<hpaste> tphyahoo-haskel pasted "is there a more way to generate helper functions for a state type based on records?" at http://hpaste.org/4071
15:34:34<allbery_b>find the real gdb binary ($prefix/lib/ghc-$version/ghc-$version) and run gdb on it and the core file, "bt" command
15:35:07<mjrosenb>allbery_b: you mean the real ghc binary
15:35:28<mjrosenb>paczesiowa: that might not work, i think portage strips all binaries on the system
15:35:39<allbery_b>since I'm on a mac and using an (old) darcs build: gdb /usr/local/lib/ghc-6.9.20071025/ghc-6.9.20071025 /cores/core.6172
15:35:47<SamB_XP>mjrosenb: ALL?
15:35:59<allbery_b>(after ulimit -c unlimited)
15:36:00<mjrosenb>SamB_XP: errr, all binaries that it installs
15:36:02<tphyahoo-haskell>I read "haskell record types considered grungy"... I think this is the same thing that was complaining about.
15:36:39<tphyahoo-haskell>http://bloggablea.wordpress.com/2007/04/24/haskell-records-considered-grungy/
15:36:40<lambdabot>Title: Haskell Records Considered Grungy « :: (Bloggable a) => a -> IO (), http://tinyurl.com/3akjdr
15:36:43<SamB_XP>well, I suppose, with the way Gentoo users are, everything would have been built with -fomit-frame-pointer, so even if they had basic symbols a backtrace would be unobtainable...
15:36:48<ricky_clarkson>"Static type checking is a compile-time abstraction of the runtime behaviour of your program, and hence it is necessarily only partially sound and complete"
15:37:10<idnar>heh
15:37:22<mjrosenb>SamB_XP: i don't have a frame pointer. . . amd64 sort of destroyed it
15:37:36<ricky_clarkson>I think this is wrong, and cite 'id' as an example. I would ask "what's the smallest program for which static type checking is only partially sound?". Does this seem a good angle of inquiry?
15:37:36<SamB_XP>oh, did it now?
15:37:56<mjrosenb>SamB_XP: yeah. . .it confused my TA's
15:38:00<SamB_XP>even in the i386 ABI it is apparantly optional...
15:38:13<SamB_XP>I could have sworn it was mandatory!
15:38:26<mauke>why do you need frame pointers for backtraces?
15:38:29<tphyahoo-haskell>I have a suspicion this type of issue is what drove HAppS team to use TH for state boilerplate, which seems to have created its own set of issues.
15:38:32<paczesiowa>what severity should I choose? major?
15:38:36<mjrosenb>SamB_XP: yeah, it just made some things like alloca easier
15:38:48<allbery_b>and debugging
15:39:05<allbery_b>note that alloca is generally considered evil
15:39:08<SamB_XP>mauke: well, if you don't have frame pointers, you need some other way of finding the next stack frame
15:39:16<SamB_XP>allbery_b: is it now?
15:39:20<sieni>allbery_b: why is that?
15:39:28<mjrosenb>SamB_XP: {E,R}SP?
15:39:30<allbery_b>so I suspect the folks who standardized it felt little need to force everyone to cater to it
15:39:30<SamB_XP>I thought it was just considered tricksy
15:39:31<faxathisia>alloca is dumb
15:39:55<mjrosenb>faxathisia: why do you say that?
15:40:05<allbery_b>arbitrary allocation on stack is tricky and canblow up in your face if you do too much of it
15:40:11<geocalc>mac
15:40:34<allbery_b>er, who standardized the abi
15:40:35<mjrosenb>allbery_b: or if you don't know what you're doing
15:40:39<faxathisia>mjrosenb: It's not a useful procedure
15:40:53<allbery_b>mjrosenb: but that's true of C in general. "more than enough rope"
15:40:55<SamB_XP>the ABI doesn't do anything to make alloca particularly harder
15:40:55<wli>ABI's are standardized, e.g. ELF/i386
15:40:58<idnar>@pl flip $
15:40:58<lambdabot>(line 1, column 7):
15:40:58<lambdabot>unexpected end of input
15:40:58<lambdabot>expecting white space or simple term
15:41:02<idnar>@pl flip ($)
15:41:02<lambdabot>flip id
15:41:13<idnar>:t ($)
15:41:14<lambdabot>forall a b. (a -> b) -> a -> b
15:41:20<faxathisia>@pl ($)
15:41:21<lambdabot>id
15:41:26<faxathisia>@unpl id
15:41:26<lambdabot>(\ a -> a)
15:41:40<SamB_XP>... as long as the compiler helps out
15:41:41<idnar>:hoogle a -> (a -> b) -> b
15:41:42<mjrosenb>faxathisia: why is beings able to quickly allocate space in a thead safe manner not useful?
15:41:43<allbery_b>SamB_XP: it only does in the sense that the frame pointer is optional
15:41:45<idnar>@hoogle a -> (a -> b) -> b
15:41:46<lambdabot>Prelude.($!) :: (a -> b) -> a -> b
15:41:46<lambdabot>Prelude.($) :: (a -> b) -> a -> b
15:41:46<lambdabot>Control.Parallel.Strategies.($|) :: (a -> b) -> Strategy a -> a -> b
15:41:53<idnar>meh
15:42:13<faxathisia>whataer you looking for idnar ?
15:42:22<allbery_b>:t flip ($)
15:42:23<lambdabot>forall a b. a -> (a -> b) -> b
15:42:32<idnar>faxathisia: a flipped ($)
15:42:42<faxathisia>idnar: it's id.. flipped doesn't make a difference
15:42:47<allbery_b>pretty sure there's no such in the standard libs
15:42:51<idnar>faxathisia: hmm?
15:42:53<mauke>faxathisia: yes, it does
15:42:59<faxathisia>@src ($)
15:42:59<lambdabot>f $ x = f x
15:43:05<idnar>faxathisia: I mean a $< f instead of f $ a
15:43:05<mauke>map (flip id) is very different from map id
15:43:21<SamB_XP>allbery_b: all that means is that the compiler has to know about alloca
15:43:30<faxathisia>oh sorry you're right
15:43:37<idnar>:t flip id
15:43:38<lambdabot>forall b c. b -> (b -> c) -> c
15:44:22<mattam>:t flip ($)
15:44:22<lambdabot>forall a b. a -> (a -> b) -> b
15:44:30<mjrosenb>is there still a bot that has djinn running on it?
15:44:36<sieni>faxathisia: I have to admit that in C I have allocated variable size data structures on stack by recursively calling a function to get the storage in the function's stack frames and then building the data structure in the end and using it
15:44:47<idnar>@djinn a -> a
15:44:47<lambdabot>f a = a
15:44:54<faxathisia>sieni: that's fine
15:45:01<mjrosenb>whee
15:45:15<mjrosenb>@djinn (a->b) -> a -> b
15:45:15<lambdabot>f a = a
15:45:23<sieni>faxathisia: well, one can use alloca to achieve basically the same thing
15:45:26<faxathisia>sieni: I think using alloca for the same purpose is bad though because it's less clera to read
15:45:37<SamB_XP>faxathisia: how so?
15:45:40<idnar>@djinn a -> (a -> b) -> b
15:45:40<lambdabot>f a b = b a
15:45:53<faxathisia>(the storage is not explicit.. you are just generating it from some calculated value)
15:46:09<wli>That's all allocators do anyway.
15:46:24<geocalc>hehe
15:46:56<mjrosenb>ooohhh
15:46:59<SamB_XP>faxathisia: so?
15:47:03<mjrosenb>@djinn ((a->b) -> a) -> b
15:47:03<lambdabot>-- f cannot be realized.
15:47:07<wli>Anyow, I never touch alloca(). I always kmalloc(), kmem_cache_alloc(), or alloc_page().
15:47:17<SamB_XP>wli: you, sir, are a kernel hacker
15:47:26<resiak>> id (+1) 3
15:47:28<lambdabot> 4
15:47:31<idnar>mjrosenb: how would that work?
15:47:41<mjrosenb>hrmm, we need to add wli no man for kmalloc
15:47:57<mjrosenb>idnar: you mean my type?
15:48:06<SamB_XP>wli no man? is that japanese?
15:48:10<faxathisia>SamB_XP: that's just my opinion
15:48:14<idnar>mjrosenb: yeah
15:48:24<wli>I studiously avoid getting involved with mm/slab.c (or the new crap going around to supplant it).
15:48:35<sieni>well, the recursive allocation will segfault if you run out of stack.
15:48:49<mjrosenb>idnar: with the help of the functions callcc :: (a cont -> a) -> a
15:49:03<mjrosenb>and throw :: a cont -> a -> b
15:49:28<wli>I generally have to assume PAGE_SIZE or less of stack, so alloca() et al are useless.
15:49:43<idnar>mjrosenb: hoo boy
15:49:57<Saizan>?type callCC
15:50:01<SamB_XP>wli: well, yeah. such is the life of a kernel hacker
15:50:02<lambdabot>forall a (m :: * -> *) b. (MonadCont m) => ((a -> m b) -> m a) -> m a
15:50:25<mjrosenb>o right. . .callcc plays in interesting ways with monads
15:50:49<wli>It's not really all that much better in userspace. There are stackspace limits both as rlimits and in terms of threads bumping into each others' stacks to be concerned about.
15:50:54<faxathisia>?djinn ((a -> b) -> a) -> a
15:50:55<lambdabot>-- f cannot be realized.
15:51:08<wli>At least with malloc() you know up-front if it will fail.
15:51:22<Saizan>?src Cont
15:51:22<lambdabot>newtype Cont r a = Cont { runCont :: (a -> r) -> r }
15:51:25<bos>well, you know up front that it might fail.
15:51:42<bos>with an overcommitting allocator, it can succeed and blow up in your face later.
15:51:56<mjrosenb>brb
15:52:07<Saizan>?djinn ((a -> (b -> r) -> r) -> (a -> r) -> r) -> (a -> r) -> r
15:52:07<lambdabot>f a b = a (\ c _ -> b c) b
15:52:16<wli>bos: Disabling overcommitment resolves that. Disk is cheap for adding swap to back it.
15:52:25<SamB>ACTION wonders if you can disable overcommit on a process-by-process basis in a useful way
15:52:32<wli>SamB: No.
15:52:37<SamB>why the heck not?
15:52:50<wli>SamB: It doesn't even make sense.
15:52:59<SamB>what about that doesn't make sense?
15:53:05<wli>SamB: Overcommitment is interplay between multiple processes.
15:53:09<SamB>yes
15:53:16<wli>SamB: Sharing and unsharing go on.
15:53:35<wli>SamB: Non-overcommitment means reserving enough space to unshare.
15:54:07<SamB>so?
15:54:33<wli>SamB: This is innately not a per-process affair.
15:54:43<SamB>why can't you reserve enough to unshare some particular processes from the rest?
15:55:05<idnar>uhm
15:55:11<wli>SamB: Because it doesn't make a useful guarantee.
15:55:14<idnar>re: http://bloggablea.wordpress.com/2007/04/24/haskell-records-considered-grungy/
15:55:15<lambdabot>Title: Haskell Records Considered Grungy « :: (Bloggable a) => a -> IO (), http://tinyurl.com/3akjdr
15:55:31<SamB>wli: how so?
15:55:36<idnar>oh nevermind, someone already made my point in the comments
15:56:01<firefly>Linux needs a syscall to say "please unify these pages (which may be in different processes and probably are)".
15:56:21<wli>firefly: Reverse COW?
15:56:30<firefly>If the dynamic linker/loader used it, it could make shared libraries that get patched with the same fixups cheaper.
15:56:49<firefly>the syscall should just be a nop if the contents actually isn't the same.
15:56:52<wli>firefly: Not enough state bits to pull it off, so it entails massive damage to the VM.
15:56:58<fasta>If only people that wrote <10KLOC in $LANGUAGE would stop writing blogs..
15:57:14<firefly>why are state bits needed?
15:57:44<paczesiowa>thanks everybody for help with confirming that bug
15:57:47<sw17ch>i like haskell Records :(
15:57:58<SamB>wli: I was thinking you could guarentee that "none of the processes in this set will die upon touching a page because of overcommit"
15:58:02<wli>firefly: To know why you were sharing in the first place when unsharing again because you need to do something different from normal COW.
15:58:22<wli>SamB: Not possible to make that guarantee without doing it for the whole system.
15:58:35<SamB>wli: how so?
15:59:00<firefly>I don't actually want more sharing than what two forked processes end up with. It's fine if the syscall only works with one backing file at a time.
15:59:35<wli>SamB: Because it doesn't make sense. Overcommitments elsewhere can consume enough memory to make the guarantee impossible.
16:00:10<SamB>wli: eh?
16:00:22<firefly>I think SamB wants a flag that says "well, don't lie to /me/ about how much memory there really is -- when I ask for memory, I want to either get that memory or an immediate error"
16:00:56<idnar>SamB: your process can get killed because other processes overcommitted
16:00:57<SamB>you just need to reserve pages for the non-overcommitted processes...
16:01:07<idnar>the OOM killer doesn't care who allocated which memory when
16:01:19<wli>SamB: And you can't do that without non-overcommitting the rest of the system.
16:01:35<SamB>wli: I don't understand why you think this
16:01:52<firefly>wli: because that's how linux currently does it or because it simply can't be done, period?
16:02:37<SamB>explain what you think would happen to make this not work
16:02:59<allbery_b>because you can't stop the OOM killer from touching such processes without risking a system deadlock
16:03:19<allbery_b>(and likewise cannot simply omit the OOM killer if you have overcommit)
16:03:47<wli>It's a Linux limitation.
16:03:58<SamB>allbery_b: okay. so maybe the OOM killer would need some reworking
16:04:18<wli>The amount of missing infrastructure to pull this off in Linux is far beyond massive.
16:04:46<wli>And its performance impact would dwarf that of the global non-overcommit.
16:05:03<seliopou>Anybody know why I would get "Undefined symbols: _readline" when ghc is trying to link my program?
16:05:09<SamB>wli: I'm not sure why
16:05:11<allbery_b>ACTION also notes that allowing processes to avoid overcommit on an individual basis can be a DoS
16:05:17<firefly>how far could one get with LD_PRELOAD skin that changes brk and mmap to add mlocking?
16:05:29<SamB>allbery_b: point
16:05:33<allbery_b>seliopou: using --make?
16:05:36<seliopou>Yes.
16:05:51<allbery_b>what ghc version? what platform?
16:05:56<firefly>because you have the wrong version of the readline library on your machine, I think.
16:06:00<seliopou>6.6.1, osx
16:06:06<allbery_b>osx, yep
16:06:09<firefly>It's mentioned as one of the FAQ things.
16:06:28<SamB>wli: what exactly do you believe would cause this performance hit?
16:06:33<seliopou>firefly: I followed the instructions on the download page and got the framework
16:06:49<seliopou>there was something in a faq about solaris and multiple versions of the library
16:06:56<firefly>at least it's a FAQ problem for the binary version of 6.8.1 for some Linux distributions.
16:07:32<allbery_b>OSX has a similar faq enry because of some system weirdies. (specifically Apple ships a -lreadline that isn't readline)
16:07:50<allbery_b>you may need to do weirdshit to make sure the correct readline is fund
16:07:57<allbery_b>the correct -lreadline that is
16:08:11<allbery_b>if it finds the Apple-supplied one first you will be unhappy
16:08:15<firefly>I don't know how to fix it or work around it on OS X. I've been using Linux at home since '99 and I only really touched OS X on a friend's machine a couple of months ago and got severely disappointed by its non-unixy unix :/
16:08:45<allbery_b>what non-unixy aspects?
16:09:08<seliopou>I was under the impression that fixing the readline problem was as simple and installing the readline framework
16:09:29<firefly>the filesystem layout, the configuration files, what flags the various commands took (or rather NOT took). I do realize that much of what I'm used to is really GNU rather than Unix.
16:09:30<allbery_b>there are some issues caused by OSX being mach instead of unix, but others are caused by it using a freebsd userspace instead of the linux one that many newcomers to unix think is "real" unix
16:09:57<seliopou>Can you point me to this FAQ? I'm looking at GHC:FAQ on the wiki and it doesn't mention this problem
16:09:57<firefly>Linux is definitely more in line with the real unices I've used at uni than OS X is.
16:10:02<pejo>allbery_b, the stuff apple ships is libedit, just like Netbsd.
16:10:06<allbery_b>yep
16:10:24<allbery_b>but naming it -lreadline is Just Wrong
16:11:43<seliopou>I like how when I search for this problem there is a job description that says, e're particularly looking for someone who is experienced in a variety of operating system platforms and libraries. You should be able to deal with questions like "I try to build GHC on Solaris 2.3.4 and get `undefined symbol _readline'"; or "How do I link to DLLs on Windows?"; or "does the ByteString library in...
16:11:44<seliopou>...GHC 6.2.1 do XXX?".
16:11:54<pejo>seliopou, do you have GHC installed and working, but trying to build some haskell program using readline?
16:12:11<seliopou>pejo: I screwed up my old install trying to get 6.8.1 to work
16:12:31<seliopou>So I got rid of everything and I'm trying to install from scratch now with a binary distro of 6.6.1
16:13:08<pejo>firefly, not sure what you mean by a real unix, but I think my mac works surprisingly much like a sane unix.
16:13:34<allbery_b>he's already admitted he was using unix == gnu
16:13:40<allbery_b>freebsd is *not* gnu
16:13:44<firefly>I've used HP UX, SunOS, Solaris, and a tiny bit Irix.
16:14:08<firefly>All were much nicer when using the GNU tools rather than the native ones ;)
16:14:27<faxathisia>unix == gnu ? O_o
16:14:31<pejo>firefly, except that the gnu tools doesn't handle ACL's under Solaris, and .., and .., and .. - but except that they work like a charm.
16:14:40<allbery_b>common belief among linuxers...
16:14:42<faxathisia>this axiom is inconsistent
16:14:47<firefly>never liked ACLs anyway.
16:14:50<pejo>firefly, I agree though, the gnu stuff gives a nice cozy feeling when it works.
16:15:16<firefly>they take too many options, though.
16:16:21<pejo>seliopou, so you're trying to compile GHC 6.8.1, with a binary snapshot of 6.6.1, on Leopard?
16:17:41<allbery_b>6.8.1 has known issues finding the right -lreadline on OSX
16:29:39<seliopou>pejo
16:29:56<seliopou>I'm trying get the binary snapsot of 6.6.1 to work with readline
16:30:03<seliopou>If I can do that, I can get 6.8.1 to work as well
16:30:11<seliopou>as that's the only problem with my install right now
16:30:19<seliopou>Undefined symbols: _readline
16:31:32<seliopou>And that only happens when a program uses System.Readline
16:33:18<wli>SamB: The accounting is more involved, it needs new data structures, and it needs more computation during the heavily exercised accounting steps.
16:45:03<sw17ch>does hackage have a "cpan" like interface from the command line?
16:46:22<Cale>sw17ch: Yes, cabal-install
16:46:41<firefly>'cabal', but you have to install the cabal-install package first, which may be a bit of a struggle.
16:46:58<Cale>sw17ch: Make sure that when you build it, you're not using Cabal-1.2.2.0 though, because that version has a bug which makes cabal-install not work.
16:47:13<firefly>It required using runghc Setup.hs/Setup.lhs for the various packages + the occasional ghc-pkg command.
16:47:18<Cale>(This is unfortunately the version which went out with GHC 6.8)
16:47:22<sw17ch>Cale: gentoo has 1.1.6.2 as stable
16:47:59<Saizan>that's too old, i think
16:48:03<allbery_b>won't work with packages upgraded for 6.8 support
16:48:04<Cale>That may be all right, I'm not sure. I know that 1.2.1 works, and apparently HEAD works.
16:48:12<firefly>It is probably a good idea to use --user and --prefix so you have control over where the packages get installed. That should make it easier to play with different versions of ghc.
16:48:32<Cale>ACTION hopes that dons will update hs-plugins soon :)
16:48:48<sw17ch>ACTION thinks he may just stick with the basics for a while
16:48:55<firefly>(--user and --prefix as arguments to cabal when you get that far. And something similar with the arguments to runghc Setup.hs/Setup.lhs)
16:49:44<firefly>Once you've got it going, things become really easy :) it is just as easy as apt-get install, modulo the occasional bug.
16:50:27<firefly>I really recommend spending the grumpy hours it can take to install it because hackage becomes so much easier afterwards.
16:50:41<sw17ch>firefly: to be honest, i haven't touched hackage yet
16:50:56<sw17ch>the stuff in Prelude has been enough for me so far... i'm not doing anything out of the ordinary yet
16:50:57<firefly>(and you WILL be grumpy when trying to install cabal-install)
16:51:09<firefly>Data.ByteString is nice.
16:52:12<firefly>Harpy seems interesting, too.
16:52:57<Heffalump>Harpy is very cool.
16:54:32<desegnis>ACTION recognizes that now, after updating to the newest ghc release, the cabal output of `Setup.hs configure` appears massively cleaned up.
16:55:00<sw17ch>What is Harpy (short of googling it)?
16:55:11<bjornbm>Anyone used the libcurl bindings (http://varsztat.com/projects/curl/) or know how to get in touch with the maintainer?
16:55:12<lambdabot>Title: Haskell bindings for libcurl
16:55:38<desegnis>bjornbm: I think darcs uses libcurl.
16:57:14<sw17ch>firefly: ah, i remember why i was asking about hackage in the first place... libpcap
16:58:41<firefly>ACTION just installed it
16:58:49<bjornbm>desegnis: I see, but does it provide a friendly lib with haskell bindings? Guess I can dig around in the repo...
16:58:51<firefly>"cabal install --user pcap"
16:59:04<sw17ch>man, that is easy...
17:00:55<Brian`>hm... i don't even remember if i had my nick registered to irc lol
17:01:25<sw17ch>$ equery files dev-haskell/cabal
17:01:25<sw17ch>[ Searching for packages matching dev-haskell/cabal... ]
17:01:25<sw17ch>* Contents of dev-haskell/cabal-1.1.6.2:
17:01:25<sw17ch>/usr/lib64
17:01:26<sw17ch>/usr/lib64/ghc-6.6.1
17:01:28<sw17ch>/usr/lib64/ghc-6.6.1/gentoo
17:01:30<sw17ch>/usr/lib64/ghc-6.6.1/gentoo/cabal-1.1.6.2.conf
17:01:37<sw17ch>that's disappointing
17:02:13<firefly>what does "ghc-pkg list" say?
17:02:27<sw17ch>$ ghc-pkg list
17:02:27<sw17ch>/usr/lib64/ghc-6.6.1/package.conf:
17:02:27<sw17ch> Cabal-1.1.6.2, base-2.1.1, cairo-0.9.12.1, filepath-1.0,
17:02:27<sw17ch> gconf-0.9.12.1, (ghc-6.6.1), glade-0.9.12.1, glib-0.9.12.1,
17:02:27<sw17ch> gtk-0.9.12.1, gtkglext-0.9.12.1, haskell98-1.0, mozembed-0.9.12.1,
17:02:27<sw17ch> mtl-1.0.1, parsec-2.0, readline-1.0, regex-base-0.72,
17:02:29<sw17ch> regex-base-0.91, regex-compat-0.71, regex-compat-0.90,
17:02:31<sw17ch> regex-posix-0.71, regex-posix-0.92, rts-1.0, soegtk-0.9.12.1,
17:02:33<sw17ch> sourceview-0.9.12.1, stm-2.0, svgcairo-0.9.12.1,
17:02:35<sw17ch> template-haskell-2.1, unix-2.1
17:02:49<firefly>these are the packages you already have :)
17:03:00<sw17ch>hmmm... yes...
17:03:16<sw17ch>but i understand that cabal 1.1.6.2 is too old for cabal install?
17:03:45<firefly>when you try to install cabal-install you may need to install newer versions of some of these (but you will be told so automatically).
17:04:09<firefly>You may need to temporarily "hide" one of the preinstalled packages -- ghc-pkg can do that for you.
17:04:55<firefly>I haven't got the faintest idea about what version of cabal (the basic cabal library that does versioning and stuff) to use. I think I downloaded the newest and manually installed it.
17:06:07<sw17ch>hehe. alright, thanks firefly
17:06:25<firefly>Anyway, download cabal-install and try to get that going with runghc Setup.hs (or Setup.lhs) and see what it complains about.
17:06:57<firefly>once cabal works, it will handle dependencies automatically for you.
17:07:15<firefly>(works = is properly installed)
17:14:34<desegnis>bjornbm, sorry, not sure about that
17:23:33<hpaste> Big_Ham pasted "(no title)" at http://hpaste.org/4072
17:24:02<Big_Ham>Does anyone know a way I can get my code to create every possible expression availible from a list of ints??
17:24:36<Big_Ham>I have no idea how to even start going about it :(
17:25:36<Lycurgus>well you might start with the definition of the expression
17:25:38<firefly>...and a list of operators, I presume?
17:25:53<Big_Ham>the definition of the expression is at the top of the paste..
17:27:03<Big_Ham>could I do that with the stuff I currently have?
17:27:06<conal>Big_Ham: i know you didn't ask, but there's a much more elegant way to work with Maybe values:
17:27:12<conal>> liftA2 (+) (Just 3) (Just 4)
17:27:12<lambdabot> Just 7
17:27:17<conal>> liftA2 (+) (Just 3) Nothing
17:27:17<firefly>how deep do you want the expression tree to be? do you only want to use each int once?
17:27:18<Lycurgus>you could wait for Don Knuth to finish his cookbook on combinatorics (vol. 4 of the Art of Computer Programming)
17:27:19<lambdabot> Nothing
17:27:21<conal>> liftA2 (+) Nothing (Just 4)
17:27:22<lambdabot> Nothing
17:27:29<pitecus>Is it forbidden to export newtype constructors??
17:27:32<Big_Ham>each int can only be used once
17:27:36<Big_Ham>each int must be used at least one
17:27:44<xerox>> (+) <$> Just 1 <*> Just 2
17:27:44<lambdabot> Just 3
17:27:45<Big_Ham>hence the permute
17:28:00<Big_Ham>so that would give all the combinations of numbers
17:28:05<firefly>so you can get by with only Add, provided you have at least two ints?
17:28:23<Big_Ham>so, because there's a target number
17:28:33<Big_Ham>have to try and make the target number from the list of ints
17:28:37<firefly>ah.
17:28:41<Big_Ham>using +-* and/
17:29:11<Big_Ham>well, `div` technically
17:31:33<byorgey>pitecus: shouldn't be. why?
17:33:17<Big_Ham>If someone could annotate my code to give me some hints, that would superb, I don't expect a full complete answer as it's homework anyway/
17:33:35<Big_Ham>I just have no idea how to go about this
17:33:53<pitecus>byorgey, i was confused, trying to export the constructor like MakeFoo instead of Foo(MakeFoo)
17:33:55<firefly>define a function that returns a list of possible trees, start with just Add.
17:34:03<bakert_>is there some base version of lambdabot on which a novice could base a very simple IRC bot?
17:34:07<firefly>handle the target later.
17:34:08<byorgey>pitecus: ah, I see =)
17:34:25<bakert_>?where lambdabot
17:34:26<lambdabot>http://www.cse.unsw.edu.au/~dons/lambdabot.html
17:34:27<Big_Ham>a list of possible tree?
17:34:31<firefly>yes.
17:34:37<Big_Ham>hmm, ok
17:35:02<firefly>let it take a list of ints (or possibly an int and a list or two lists or some variation thereof)
17:35:06<byorgey>bakert_: probably not. but what about dons' 'roll your own IRC bot' article?
17:35:12<byorgey>@go roll your own IRC bot
17:35:12<bakert_>byorgey: sounds good
17:35:12<lambdabot>http://haskell.org/haskellwiki/Roll_your_own_IRC_bot
17:35:17<bakert_>thanks
17:35:47<Big_Ham>ok, thank you firefly
17:36:06<firefly>you might want to combine that with a function that splits apart a list into an element and the rest of the list in all possible ways, ie. that returns a list of such splits.
17:36:32<Big_Ham>that doesn't matter because each int HAS to be used once
17:36:39<firefly>at least that's how I would start. Once one explores a bit one tends to get an "aha" moment and understand the problem much better.
17:36:41<Big_Ham>so just a list of all combinations is sufficient
17:36:48<Big_Ham>lol
17:37:05<firefly>the list of splits thing may make it easier for you to generate all the possible trees with Add.
17:37:29<Big_Ham>so I need to create a tree of Expre's right?
17:37:48<firefly>Expre *is* a tree.
17:37:57<Big_Ham>?
17:38:01<firefly>!
17:38:05<Big_Ham>in a way i suppose
17:38:21<Big_Ham>i never thought to look at it that way
17:38:26<firefly>not "in a way" or "i suppose"! It very definitely *IS*.
17:38:31<Big_Ham>lol
17:38:39<Big_Ham>ACTION just got owned
17:39:38<firefly>Draw a little picture of the tree "Add (Sub (Lit 3) (Lit 2)) (Lit 9)" :)
17:40:12<Big_Ham>yeah, I see what you mean
17:40:22<firefly>You might want to rename your constructors to Add, Sub, Mul, Div, Lit so they all line up nicely in case expressions if you are going to need those.
17:40:57<Big_Ham>ok
17:41:15<firefly>(and use the trick from conal to turn all the value cases into one-liners)
17:42:07<byorgey>Big_Ham: note liftA2 requires importing Control.Applicative.
17:42:24<Big_Ham>ok, thanks by
17:42:32<conal>Big_Ham: why do you toss negatives?
17:42:55<Big_Ham>because they aren't allowed as an intermediate value
17:43:03<Big_Ham>neither are fractions
17:43:06<conal>why not?
17:43:15<Big_Ham>that's the question
17:43:23<Big_Ham>i guess it makes it slightly more simple that way
17:43:43<Big_Ham>although not a great deal
17:43:58<Cale>What is the question?
17:44:27<byorgey>I think it actually makes it more complicated that way =)
17:44:30<Big_Ham>lol
17:44:56<conal>also, what does your program give for value (Sub (Lit 3) (Lit 4)) ?
17:45:00<Big_Ham>Take a list of ints and a target int and return the expression if their is one that equals the target number
17:45:10<Big_Ham>Nothing
17:45:16<Big_Ham>*there
17:45:24<conal>Big_Ham: you sure?
17:45:28<Big_Ham>should do
17:45:53<Big_Ham>nah, syntax error :S
17:46:07<Big_Ham>I would have expected it to return nothing
17:46:20<conal>Big_Ham: there's no case that fits.
17:46:41<hpaste> _fang pasted "type error" at http://hpaste.org/4073
17:46:41<Big_Ham>pattern match failiure
17:46:49<conal>yeah
17:47:00<_fang>i just pasted something, and the error i get is in there... can anyone help me?
17:47:07<conal>Big_Ham: i don't think excluding negatives is helping you any.
17:47:33<conal>also, from where comes does the requirement of using only distinct members of the int list?
17:48:00<conal>it's doable but certainly trickier than without the requirement.
17:48:16<Big_Ham>That's the question I've afriad
17:48:36<Big_Ham>*I'm afraid
17:48:42<conal>ok
17:48:48<Big_Ham>anyway, thanks for your help guys, I'm off
17:48:57<conal>good luck, Big_Ham
17:50:38<byorgey>_fang: because you use x in the expression (y:x), it must be a list... but you pass it to dist which expects an Int.
17:50:49<byorgey>perhaps you meant y ++ [x] instead of y:x?
17:52:22<byorgey>_fang: I would suggest giving all_paths_between an explicit type signature. That will probably help you track down your type errors more easily.
17:52:44<firefly>how does forkOS work in terms of low-level stuff?
17:53:01<vwx>i imagine it's pretty complicated
17:53:01<firefly>somebody told me there was a bad interaction with the heap or garbage collector -- is that true?
17:53:10<firefly>where should I start digging?
17:53:55<firefly>almost all the articles I've found about haskell and threads talk about forkIO only.
17:54:35<_fang>byorgey: yes! guess it'll do. i'll do it as soon as i finish finding out what i want with it! lol! i'm in a deep trouble with this. thx =D
17:55:55<vwx>firefly: forkOS is the same as forkIO, it just makes sure that all ffi calls go through the same OS thread
17:56:57<firefly>so each time forkOS is invoked, a new OS thread is created that the new haskell thread gets mapped onto -- so it creates a 1:1 relation between them?
17:57:36<firefly>if any of them did a forkIO would that share the same native OS thread as the haskell thread that called it?
17:57:44<vwx>i'm not sure, but i don't think that's how it works
17:57:59<byorgey>...I thought it was the other way around? Not that I know all that much about it.
17:58:53<firefly>I want to use real native threads to send many file I/O requests off to the operating system and give it a fighting chance to read the file(s) in a sensible order.
17:59:28<firefly>if the run-time system decides that only one of its native threads can issue I/O at a time then I've got a problem.
17:59:48<firefly>Also, if using forkOS impairs the garbage collector then I may have a problem.
18:00:15<Cale>I think that if you just use forkIO, things will generally work sensibly.
18:00:25<firefly>It looks like there is a "Big RTS Lock" akin to the Big Kernel Lock that Linux has.
18:00:34<Cale>Is there?
18:00:52<firefly>Cale: read/write are not the only OS calls that can block. Opening a file can block, creating a file can block, etc.
18:01:11<firefly>That's what docs/comm/rts-libs.html seems to say.
18:03:27<Cale>firefly: Are you using foreign libraries to do I/O?
18:03:33<firefly>Not yet ;)
18:03:39<firefly>(I don't think I will, actually)
18:04:06<firefly>I might want to fire off an fadvise or madvise in a separate OS thread, though.
18:04:33<firefly>(they tend to block in most (all?) versions of Linux, hence the desire for a separate thread)
18:05:59<Cale>Basically, AIUI, the RTS manages a pool of OS threads which manage Haskell threads. A given Haskell thread can be run by one OS thread or by many during its lifetime.
18:06:40<firefly>yep. That's my understanding, too. This mental model works fine with forkIO. It breaks a bit with forkOS, though.
18:07:38<vwx>forkOS is the same thing as forkIO, it only adds compatibility for C libraries that use thread-local storage
18:07:55<Cale>Well, the only change with forkOS is that it ensures that the new Haskell thread is bound to a fixed OS thread.
18:08:19<Cale>All forign calls made by that Haskell thread will be made using that one OS thread.
18:08:25<Cale>foreign*
18:08:45<firefly>so it's just a binding thing. good. That matches what I wrote initially. Does that binding continue for a child thread if such a bound thread does a forkIO?
18:08:51<Cale>Which is important when interacting with certain not-so-threadsafe libraries.
18:08:55<firefly>yep :)
18:09:24<vwx>Cale: but two forkOS threads, can still end up running on the same OS thread, right?
18:09:26<Cale>No, I don't think it does. If you do a forkIO, I'm fairly sure that'll create a new unbound Haskell thread.
18:09:41<firefly>and certain thread-safe, too. I don't think it's unreasonable to demand that some calls must be done from within the same OS thread.
18:09:52<Cale>Apparently forkOS creates a new OS thread when it's used.
18:10:01<firefly>as long as the library /does/ allow more than one thread to use it.
18:11:02<Cale>It's not necessary to use forkOS to get non-blocking IO
18:11:24<Cale>and it's also not necessary if you want threads to run in parallel on a multiprocessor
18:11:54<vwx>but what if you want threads to run in parallel on a uniprocessor?
18:12:06<firefly>I thought the run-time knew about read/write calls and switched file handles into non-blocking mode + used select to handle them nicely.
18:12:14<Cale>vwx: That's kind of impossible :)
18:12:37<firefly>Which is good and stuff. But madvise() will just block while reading the file into memory if it isn't there already. Nonblocking mode or not. It doesn't matter.
18:12:59<vwx>Cale: no it's not, an execution thread does I/O in addition to running cpu code
18:13:28<firefly>I mainly want to ensure that the I/O is properly overlapped and scheduled.
18:13:57<Cale>vwx: The Haskell scheduler will make sure that threads are switched between in a reasonable manner even on a uniprocessor.
18:14:29<vwx>Cale: what about heavy use of foreign functions?
18:14:48<vwx>like a blocking foreign function?
18:16:00<Cale>If a foreign call blocks, then Haskell code continues to execute in other OS threads.
18:16:55<vwx>but on a uniprocessor there is only one OS thread, right?
18:17:04<firefly>there might be more.
18:17:11<Cale>No, there might be many.
18:17:25<firefly>ghc has a pool of worker threads which it is supposed to grow (and shrink) automatically.
18:17:30<vwx>so it's a guessing game? sometimes the program may run fast, and sometimes slow?
18:17:48<Cale>Sorry?
18:18:20<vwx>hm...
18:18:45<Cale>The runtime system manages a pool of worker OS threads each of which normally tries to aquire Haskell threads to run.
18:19:11<vwx>is the pool of worker OS threads a fixed size, from the -N RTS option?
18:22:07<firefly>ok, I've given up on the documentation and started reading the code (which I probably should have done right away).
18:22:22<Cale>I think -N controls the number of OS threads which are allowed to concurrently execute Haskell code. (and the initial number of OS worker threads created by the runtime)
18:22:40<firefly>I think there is a subtle error in forkOS_createThread() in rts/posix/OSThreads.c.
18:23:09<firefly>pthread_create() returns 0 if the thread got created and !0 if creation failed.
18:23:47<firefly>If the creation failed, pthread_detach(tid) gets called (why, if the thread creation failed?)
18:24:03<sk>what is this discussion about?
18:24:04<firefly>&tid was passed to pthread_create() and filled in in case of success.
18:24:47<firefly>But what if pthread_creat() failed? Does it set tid in that case? If it doesn't, we end up having pthread_detach() with a garbage thread id, which may be one we didn't want detached.
18:24:56<firefly>sk: I'm trying to learn how forkOS works.
18:25:06<Cale>firefly: Sorry, which code are you looking at?
18:25:11<Cale>firefly: GHC 6.8.1?
18:25:16<firefly>darcs version.
18:25:19<Cale>ah
18:25:52<sk>ic... good luck =)
18:26:10<firefly>:)
18:27:04<firefly>same thing in createOSThread().
18:27:11<Cale>There are probably people around who know this stuff much better than I do.
18:27:47<Cale>Are you experiencing problems with concurrency?
18:28:21<firefly>not yet. I'm trying to get a good mental model all the way down from the refined airs of beautiful haskell down to the metal.
18:28:39<firefly>I lack an understanding of the stuff between forkIO and forkOS and native pthreads.
18:28:53<Cale>firefly: Remember that it's all subject to change with each release of GHC :)
18:29:02<firefly>sure, no problem with that :)
18:29:50<Cale>There have been some papers that seemingly advocate a new RTS which would allow for user-specified scheduling.
18:30:16<firefly>You are thinking of "Lightweight concurrency primitives for GHC" (Peng Li et al) ?
18:30:41<Cale>Right, yes
18:30:43<Cale>http://www.haskell.org/~simonmar/papers/conc-substrate.pdf
18:31:02<firefly>It ignores the issue.
18:34:00<Cale>Um, that code looks okay to me.
18:34:08<Cale>er...
18:34:22<firefly>what is the value of tid when pthread_detach gets called?
18:34:53<Cale>pthread_create gives 0 when successful
18:34:59<firefly>yes.
18:35:51<firefly>I realize it's a corner case but ulimits may cause a program to run into a thread creation limit long before the machine is any way loaded.
18:36:13<Cale>and it stores the ID of the created thread in the location referenced by the pointer which is its first parameter
18:36:27<Cale>So tid gets set to the created thread's ID.
18:36:39<Cale>and then pthread_detach is called with that tid
18:37:00<firefly>but when pthread_create is successful, we don't call pthread_detach() .. oh, wait. I got a bit flipped.
18:37:10<firefly>:(
18:37:57<Cale>Yeah, using 0 for success is a funny idiom.
18:38:07<firefly>ok, the next question is "if we want the new threads to be detached, why don't we create them in that state? the current code let's them run in attached state for a bit which is racy if it really is so important to be detached"
18:38:19<firefly>pthread_create() can take an attribute for that.
18:38:52<Cale>pthread_detach just means that the storage for the thread can be reclaimed when the thread terminates.
18:39:24<Cale>hmm
18:39:52<Cale>So you're saying that the thread might finish before the call to pthread_detach?
18:39:56<firefly>yes.
18:40:10<firefly>it most likely won't, but there is a race there.
18:40:33<Cale>I wonder if that's really a problem. I suppose it depends on exactly how pthreads work. (I'm not entirely familiar)
18:41:10<Cale>It sounds like if the thread is still attached then it won't be deallocated.
18:41:12<firefly>even if it's wrong, it is unlikely that anybody runs into it. The race is small.
18:41:16<Cale>(even when it terminates)
18:41:41<Cale>So it might not actually be an issue, simply because of the nature of attachment. But I'm not sure about that.
18:49:15<Cale>As far as I can tell, it's okay to call pthread_detach on an already exited thread.
18:49:25<firefly>good.
18:49:51<firefly>hey, there's still a race :)
18:50:31<firefly>if the thread exits and sufficiently many new threads are created, the thread id may be reused before pthread_detach() is called ;)
18:51:03<firefly>(actually, I think the implementation holds onto the thread id until the thread is used in pthread_join() or has been detached and auto-released)
18:51:28<firefly>(it may even be in the POSIX threading standard, for all I know)
19:04:11<Cale>That latter behaviour seems like the only right thing to do.
19:04:11<Cale>Reusing the thread id before a join or detach would be really evil.
19:04:11<firefly>yes :)
19:04:11<firefly>Unfortunately, it's been a few years since I last looked at the spec :/
19:04:11<vwx>does ghc use pthreads also on windows?
19:04:11<firefly>as far as I can tell, yes.
19:04:11<firefly>mingw probably maps it onto win32
19:06:11<vwx>probably uses http://sourceware.org/pthreads-win32/
19:06:11<lambdabot>Title: POSIX Threads (pthreads) for Win32
19:30:55<hpaste> sizur pasted "link error" at http://hpaste.org/4074
19:32:28<dmwit>sizur: What's the output of ghc-pkg list?
19:33:30<sizur>dmwit: my friend insalled a binary distro. and it was not easy
19:33:52<sizur>in user space
19:34:00<sizur>so that can be a clue
19:35:34<hpaste> sizur annotated "link error" with "ghc-pkg" at http://hpaste.org/4074#a1
19:36:32<firefly>Cale: the thread/rts code doesn't seem too bad, actually. I think I can crack it in a couple of days, max.
19:36:40<dmwit>huh, glut and opengl are exposed
19:37:00<sizur>it's on gentoo system in user space
19:37:17<dmwit>Is the real libGlut and libGL on the system?
19:37:25<sizur>how to check?
19:39:22<sizur>he has freeglut installed
19:40:08<dmwit>Okay, so there's some /usr/lib/libGL.so and /usr/lib/libglut.so?
19:41:55<dmwit>In that case, I'm not sure.
19:43:27<sizur>ok, he made it to work. apparently package.conf from fedora rpm is not compattible with something. i have no idea what went wrong. he made it to work by replacing the package.conf from bzip distro
19:43:50<sizur>dmwit: thank you very much for trying to help :)
19:57:59<dmwit>I just got Youtube spam from my mother. =/
19:58:20<vwx>shit happens :(
19:58:50<dmwit>Yes, and now you have complaint spam from me! It propagates... =)
20:06:55<seliopou>I asked this question earlier but nobody was around that seemed to know what was going on, so I'm going to ask again.
20:07:10<seliopou>I'm trying to install ghc 6.8.1, and everything works, except for the System.Readline library.
20:07:31<seliopou>When I try to compile a program that uses it, ghc fails at linking with the error, "Undefined symbols: _readline"
20:07:41<shachaf>seliopou: Do you use --make?
20:07:46<seliopou>Yes.
20:08:00<shachaf>seliopou: What version of readline do you have installed?
20:08:08<seliopou>I'm using OS X, The third binary distribution listed under the intel section
20:08:16<seliopou>GNUreadline.framework
20:08:32<seliopou>In addition, I have one installed in /opt/local since it's a dependency for some other stuff
20:09:30<shachaf>seliopou: Which version? I understand GHC likes an older version of readline.
20:10:10<seliopou>It's version 5.2, the one linked to by the installation instructions
20:10:38<shachaf>Hmm, I thought GHC used readline4.
20:10:58<shachaf>Maybe not on OSX.
20:11:17<seliopou>shachaf: GHC on OS X is a mess
20:12:49<seliopou>What's particularly irritating is that if I remove the framework, it complains that the library isn't present, so I'm pretty confident it's finding the right copy of readline
20:13:06<seliopou>and furthermore, the symbol that it claims is undefined is there...
20:14:23<firefly>no, it is not a sign that it finds the right copy of readline -- it means it finds /a/ copy of readline (which evidently is not the right one).
20:14:41<firefly>oh, fun, hadn't seen the part about the symbol actually being there.
20:15:03<seliopou>The instructions state that it uses the GNUreadline.framework
20:15:22<seliopou>When it is not present, I get an error saying it is not present. When it is present, I get an undefined symbols error.
20:15:34<seliopou>Ah
20:17:56<firefly>what's your DYLD_xxxx environment variables say?
20:18:43<seliopou>I don't have it set
20:20:14<seliopou>One interesting thing: What's failing is /usr/libexec/gcc/i686-apple-darwin8/4.0.1/collect2 with a great number of options
20:20:15<firefly>try setting DYLD_FRAMEWORK_PATH or DYLD_FALLBACK_FRAMEWORK_PATH.
20:20:22<seliopou>one of which is -framework GMP
20:20:33<seliopou>but there is no similar option for the readline framework
20:21:28<seliopou>Nothing
20:21:32<seliopou>same error
20:22:00<firefly>the complaint about the library missing, does it occur during link or when you try to run the program?
20:23:04<seliopou>Link time
20:23:31<firefly>too bad :(
20:23:39<seliopou>But just so we're clear, I'm not getting a missing library/framework error right now, just the undefined symbols error
20:23:58<seliopou>Yeah, it's really unfortunate that installing ghc has to be such a pain on OS X
20:24:59<firefly>how about passing -optl '-framework readline' to ghc (or something like that) ?
20:25:08<firefly>-optl means "pass this option to the linker"
20:25:17<firefly>(just like -Wl,xxxx for gcc)
20:28:08<seliopou>firefly: on OS X, you can just use -framework name
20:28:11<seliopou>and now it compiles
20:28:20<seliopou>This is really bizarre
20:28:27<bparkis>I was thinking--consider the execution of a program that has read/write access only to a block of memory. if you prove things (like loop invariants) about the execution of this program, you are actually proving that certain states of the memory cannot occur
20:28:50<seliopou>firefly: Thanks for your help
20:28:54<seliopou>I can get my program to link now
20:29:07<firefly>you are welcome -- but did I even do anything? Things just work for you now, don't they?
20:29:41<seliopou>I mean, you suggested explicitly passing -framework GNUreadline to ghc
20:29:45<bparkis>and if you consider a static type system to be a set of inferences about a dynamic type system with type tags, the type checker is proving that certain states of the memory--those with invalid type tags--do not occur
20:29:50<seliopou>Which is something it should have been doing on it's own
20:30:03<firefly>and that's what made it work?
20:30:11<bparkis>and discarding those invalid states from the beginning by doing away with the type tags
20:31:00<seliopou>firefly: Yes
20:31:20<firefly>weird. Ghc is apparently not quite polished yet.
20:31:22<seliopou>So as long as I use that every time I use System.Readline, I'm good
20:31:25<firefly>:)
20:31:28<bparkis>so I was wondering, can you do something similar--paring down invalid states from the beginning--with any other property of the program?
20:31:31<seliopou>Yeah
20:31:36<seliopou>I suppose I should tell somebody about this?
20:31:44<firefly>probably.
20:31:46<seliopou>It seems odd that nobody has found this yet.
20:31:47<EvilTerran>@where bugs
20:31:47<lambdabot>I know nothing about bugs.
20:31:56<ddarius>@bug
20:31:56<lambdabot>http://hackage.haskell.org/trac/ghc/newticket?type=bug
20:31:59<seliopou>I presume not a lot of people that use OS X use System.Readline
20:32:00<ddarius>bparkis: Sure.
20:32:13<seliopou>thanks
20:32:13<EvilTerran>@where+ bugs http://hackage.haskell.org/trac/ghc/newticket?type=bug
20:32:13<lambdabot>It is forever etched in my memory.
20:32:26<firefly>I've reported one bug and I did get a reply a couple of days later (roughly "yep, you are right. Dunno what a good solution would be.")
20:32:26<bparkis>well ddarius what I mean is, with _every_ other property of the program
20:32:33<EvilTerran>I'd almost certainly've forgotten that as a special case the next time i wanted it ;)
20:32:51<bparkis>in the limit case paring down the program until _every_ state of memory can occur (dependent on the input)
20:32:58<firefly>ACTION halts!
20:33:11<firefly>or not?
20:34:42<EvilTerran>if you've got finite memory, we can work it out by exhaustive analysis, firefly ;)
20:35:36<bparkis>for instance if you know that an integer is always in the range 0 to 3, representing it by 2 bits instead of 16
20:36:32<newsham>I found out they sold me a large finite state machine :(
20:36:56<firefly>would you rather have very long tapes?
20:37:04<newsham>as long as it was semiinfinite
20:37:12<newsham>at least it would be turing complete
20:37:21<firefly>bparkis: you can do some analysis of that sort, yes, but you can't do as much as you probably want to.
20:37:48<monochrom>I'm happy I paid finite money for a finite machine! :)
20:38:00<bparkis>i mean in theory--in theory is there some set of program transformations that can alter a program to use less memory, given some invariant about the program's execution
20:38:03<firefly>There have been a few experimental compilers for C and hardware description languages that did perform such analyses precisely in order to get by with fewer bits.
20:38:20<bparkis>until eventually there are no invariants about the program's execution and it uses the minimum memory possible
20:38:21<EvilTerran>with an appropriately extensible distributed computing system and unlimited buying power, you could create something that tends towards turing-completeness as time passed tends to +inf, which'd be the best you could do in theory anyway ;)
20:38:35<firefly>The ones that describes digital hardware were used/could be used to synthesize logic so the narrower buses and registers, the better.
20:39:11<firefly>The C and C-like ones were intended for energy efficiency: the fewer bits you work with, the fewer bits have to toggle (or even be enabled) => the less energy the computer will require.
20:39:20<firefly>There are papers on this available on citeseer.
20:39:44<EvilTerran>bparkis, i think in the end you'd end up with an almost literal representation of a FSM
20:40:42<firefly>other things to look at: supercompilation and partial evaluation. Plus perhaps the paper about driving in the jungle (by Jens Peter Secher) which I must admit I don't understand.
20:40:43<EvilTerran>er, DFA. whatever.
20:40:48<firefly>+ stuff on abstract interpretation.
20:40:51<vwx>are there any html templating engines for haskell? chunks is cool, but are there others?
20:40:55<bparkis>ah yes, that's true--it would end up just being the state minimization algorithm
20:41:22<bparkis>sort of
20:41:24<EvilTerran>and you'd have trouble reducing it to exactly 2^n states
20:41:42<EvilTerran>although you could always introduce equivalent states to get that
20:41:52<bparkis>there's a problem with that, namely that a computer can execute when it is not reading input
20:42:09<bparkis>whereas a FSM can only execute one step per symbol of input
20:42:35<wli>A computer receives a clock signal.
20:42:38<EvilTerran>if you're dealing with finite memory, you might as well merge all the steps from one token of input to the next
20:42:48<wli>Which is essentially an input.
20:43:05<bparkis>yes and that would probably minimize the memory used
20:43:22<firefly>wli: it doesn't have to.
20:43:25<EvilTerran>and you'd be left with a meaningless number as your state
20:44:02<EvilTerran>and a giant graph with very little semantic meaning as your program
20:45:07<EvilTerran>another problem, though: if we're working from the same term of "invariant", they can refer to things other than the current state
20:45:32<wli>Asynchronous computers would just treat the completion of an instruction like a clock signal is treated by synchronous computers now, essentially in a feedback loop.
20:45:32<EvilTerran>eg, things that've happened in the past, or the most recent event, or whatever. i guess you could encode those into the state, but it seems messy
20:45:40<bparkis>no they can't EvilTerran
20:46:00<wli>IOW lazy evaluation in hardware.
20:46:00<bparkis>invariants can only restrict the current state or interpret it
20:46:15<bparkis>because the next state only depends on the current state
20:46:47<goalieca>async compuers though would theoretically use lots less power.. and the routing of the clock signal would no longer be a problem
20:46:51<goalieca>no clock skew :-)
20:47:02<wli>goalieca: Wrong kind of clock.
20:47:30<EvilTerran>meh. okay then, we'll go with your definition
20:47:36<wli>goalieca: This is all internal to the CPU anyway. The rest of the system sees a normal CPU.
20:48:28<bparkis>it's not just a definition, there is no invariant that you can state that does more than restrict the current state or interpret it
20:48:37<goalieca>ACTION admits to have not read the whole convo
20:48:48<wli>goalieca: I also came in late.
20:49:09<bparkis>assuming that the program only reads/writes to the memory
20:50:32<wli>Computers are just large repositories of state (register files, TLB's, L1/L2/etc. caches, RAM) and finite control. Ultimately it comes down to a calculator with wires on boards instead of buttons.
20:50:42<wli>"Finite control" means FSM.
20:51:07<EvilTerran>bparkis, it's a definition in that the word can be used to mean other things. death by semantics, an' all that.
20:51:15<EvilTerran>but now i have to be elsewhere. laters.
20:51:17<bparkis>ok
20:51:33<Olathe>wli: La la la la la ! I can't hear you ! La la la la la !
20:51:37<wli>I take it my commentary here wasn't helpful.
20:52:14<bparkis>although that does bring up a point, that real computers allow only certain transitions from one state to another, not arbitrary ones
20:52:44<bparkis>so you could call that an invariant on any 2 consecutive states instead of just one
20:53:05<wli>bparkis: Or an invariant on the state transition function.
20:53:08<bparkis>but that's not so much about the program as it is about the architecture
20:53:13<bparkis>yes wli
20:54:41<wli>I don't completely understand the low-level operation of asynchronous computers, but they aren't fundamentally different AIUI.
20:55:23<bparkis>so optimization of a program at the machine level is the problem of finite state machine minimization, subject to certain constraints on the state transition function
20:57:46<bparkis>well, almost, because of the problem of execution without input
20:58:47<bparkis>which can be interpreted as state transitions on the empty string
21:02:26<bparkis>so i assume that finite state machine minimization, _with_ a restricted state transition function, is a hard problem
21:03:13<dmwit>State transitions on an empty string can be turned into normal state transitions, no?
21:03:24<bparkis>not if the state transition function is restricted
21:03:25<dmwit>i.e. epsilon-NFA's are equivalent in power to DFA's
21:03:44<dmwit>What do you mean by restricted?
21:04:05<bparkis>for example if you can only transition from one state to another if there is a machine instruction that does it
21:04:48<dmwit>That's just the usual definition of a transition function, what's the restriction?
21:05:14<bparkis>machine instructions being from a real computer chip, and fixed
21:05:44<dmwit>How much have you learned about finite state automota?
21:05:50<dmwit>s/automota/automata/
21:06:12<newsham>are you talking about a finite state acceptor? or a finite state transducer?
21:06:21<bparkis>well, undergrad course + honors colloquium, and I got an A
21:06:43<bparkis>for example suppose you have a loop that places, over the course of 50 instructions, the square of a number in one memory location into another
21:07:03<bparkis>this is 50 (restricted) transitions on the null string
21:07:20<bparkis>and it can't be condensed into 1 unless there is also a squaring instruction
21:07:57<dmwit>ooooh, ok
21:08:03<dmwit>Now I'm with you. =)
21:08:06<newsham>doesnt sound like you're talking about FSM's
21:08:06<hpaste> noob annotated "do know how to iterate, please help" with "what if i don't want putStrLn "Welcome to Mastermind" in loop" at http://hpaste.org/4055#a6
21:08:49<dmwit>noobie: mastermind = putStrLn "whatever" >> mmloop (atries - 1)
21:08:50<noobie>i am looping something but i don't want the welcome mesage to be looped
21:09:15<dmwit>noobie: Actually, you'd have to do it one level higher than mastermind, I guess.
21:09:25<noobie>how?
21:09:27<newsham>noob: why are you making one very large copmlex function?
21:09:31<dmwit>noobie: In any case, just move the putStrLn out of the loop, like you would in any language.
21:09:34<newsham>instead of lots of really small easy to understand functions?
21:09:35<noobie>can u anotate pleas
21:10:14<bparkis>let a machine specification, K, be a set of states and a set of state transitions between those states, where some of the transitions may be null transitions and the machine may have more than one transition per symbol for a state
21:10:40<noobie>i am gonna do a readFile, but i want it to read and print only once
21:11:08<bparkis>let a finite state machine restricted to K, called a K-FSM, be a subset of those states and transitions, such that the K-FSM has at most one transition per symbol for a state (including at most one transition for the null string)
21:11:36<noobie>any help?
21:11:41<bparkis>a K-FSM is an approximation of a computer program running on a computer with a fixed memory and fixed instruction set
21:12:22<dmwit>noobie: I think you can figure this one out on your own. I'll give you a hint: you need another top-level function that prints your message (once), then starts the loop.
21:12:37<noobie>ok
21:12:42<noobie>jus got it
21:12:47<dmwit>noobie: But, I think this function is a bit long, and you may not be taking full advantage of Haskell's abilities.
21:13:04<noobie>wat
21:13:05<Mr_Awesome>dmwit: well, he is a noobie ;)
21:13:21<noobie>i am a newbie help!!!!!!!!
21:13:24<newsham>and he just got good advice. noobie, rewrite simpler small pieces
21:14:14<Mr_Awesome>im not against the advice
21:14:32<dmwit>You might want a function like "nextStep :: String -> IO ()" or so that handles a single line of input.
21:14:43<newsham>noobie: you prompt the user for his last guess but never look at it, when tries drops to zero
21:14:46<dmwit>Then you can use pattern matching to get rid of all the if/then/else clauses in there.
21:14:47<newsham>thats kind of rude :)
21:15:13<dmwit>newsham: I... don't think that's true.
21:17:48<newsham>dmwit: guess <- getLine. if tries == 0 then putStrLn "Game Over, ..."
21:17:58<dmwit>oh
21:18:00<newsham>else if guess == code ...
21:18:03<dmwit>ACTION is often wrong
21:19:04<newsham>should check tries after checking guess, and right before recursing
21:20:03<noobie>i tried putting it putside the loop but i got an erro
21:22:10<newsham>promptLoop prompt state proc = do { putStrLn prompt; hFlush stdout; guess <- getLine; case proc state guess of Nothing -> return (); Just state' -> promptLoop prompt state' proc
21:22:41<newsham>err I guess proc would have to be an action not a function
21:23:56<newsham>mstate <- proc state guess; case mstate of ...
21:29:56<noobie>i can't get to not loop
21:30:39<noobie>i built a game and i draws a random value from a file, but everytime it loops it changes
21:30:54<noobie>don't know what to do
21:31:12<newsham>dont understand the problem
21:33:37<noobie>i ave a file with codes in it e.g. [1,2,2,3,3,4,4], i use the index function to take one of them and the user as to guess it
21:33:49<noobie>if it changes he will never
21:33:51<noobie>win
21:34:10<noobie>readFile <- "code.txt"
21:34:26<noobie>file !! (index)
21:34:37<noobie>user as to guess that value
21:34:51<noobie>the loop is changing the value
21:37:34<newsham>so dont make the loop change its value?
21:38:31<noobie>how?
21:38:44<newsham>i dunno.. how did you make the loop change the value?
21:39:00<newsham>you're asking specific questions about code that you have
21:39:06<newsham>I cant possibly answer it
21:39:12<newsham>(also your questions are somewhat vague)
21:39:15<noobie>it gives the user 8 tries
21:39:43<noobie>on each try the it changes the value
21:39:57<noobie>in other words i want to read the file once
21:39:58<newsham>so make it not change the value on each try
21:40:06<newsham>make it read the file just once
21:40:07<noobie>how???
21:40:13<newsham>read the file
21:40:19<newsham>then run your loop
21:40:34<newsham>you're trying to do so many things in your function
21:40:40<newsham>i'm not suprised its confusing you
21:40:45<newsham>you need to make little baby steps
21:40:50<newsham>not do everything all at once
21:40:56<noobie>it is a game
21:41:03<noobie>and it is dew monday
21:41:21<newsham>yes. so you need to think of your game and how it breaks down into small problems
21:41:27<newsham>and write solutions to each of those small problems
21:41:39<newsham>not write one big honking function that does the wholething
21:43:23<newsham>here's an example. you could write a function which runs the main game loop, then asks the user if he wants to go again or not
21:43:26<newsham>and loop if he does
21:43:29<newsham>and dont loop if he doesnt
21:43:38<newsham>thats a small 3-line function
21:43:38<noobie>Syntax error in input (unexpected `<-')
21:44:11<newsham>let me know when you have a question
21:45:47<noobie>:e
21:46:30<noobie>i wrote this
21:46:32<noobie>cod = do
21:46:32<noobie> codeDB <- readFile "code.txt"
21:46:38<noobie>outside the loop
21:46:42<noobie>getting a erro
21:49:11<newsham>what error are you getting?
21:49:27<noobie> Syntax error in input (unexpected `<-')
21:50:06<newsham>thats not what I get when I do that same thing
21:51:25<dmwit>noobie: The more you hpaste, the better we can help you.
21:51:36<noobie>ok
21:51:54<newsham>you need to come up with a question, ask it, and then listen to and accept the answer
21:52:54<hpaste> (anonymous) annotated "do know how to iterate, please help" with "(no title)" at http://hpaste.org/4055#a7
21:52:57<noobie>there
21:53:59<noobie>i am trying to take the codeDB <- readFile "code.txt" out the loop
21:55:05<newsham>do you have a question?
21:55:24<noobie>how do i take it out the loop?
21:55:45<newsham>why dont you read your data before calling mmloop?
21:55:46<noobie>is dat a difficult ques?
21:55:53<newsham>and pass it in to mmloop?
21:56:14<noobie>yes
21:56:28<noobie>i want the code to be retrieved once
21:56:44<newsham>so before calling mmloop, read it and pass it in to mmloop
21:57:09<dobblego>does the Either ADT have another name in different fields?
21:58:33<newsham>mmloop happens every time you ask the user for another value
21:58:44<newsham>things that you dont want to do every time shouldnt be done in mmloop
21:59:02<ddarius>dobblego: sum or or or disjoint union
21:59:12<ddarius>or coproduct
21:59:23<dobblego>ddarius, can you please use parentheses? :)
21:59:43<noobie>how do i take it out
21:59:52<dobblego>(sum) or (or) or (disjoint union)?
22:00:01<noobie>thats what i av been askin u for the past hour
22:00:14<noobie>r u gonna help or not
22:00:23<newsham>noobie: I dont know how to answer that question without doing your homework for you
22:00:28<newsham>you basically dont put it there
22:00:29<ddarius>dobblego: or coproduct, yes. There are others for the analogous idea in other specific fields.
22:00:32<newsham>and you put it somewhere else
22:00:44<noobie>i did most of the code
22:00:46<newsham>noobie: i can help you, but I cant do your homework for you.
22:00:53<dobblego>ddarius, great thanks
22:00:53<noobie>i just want 1 answer
22:01:13<newsham>"how do I take it out?" "you dont put it in mmloop"
22:01:17<newsham>thats as simple as I can state that.
22:01:31<noobie>where do i put it?
22:01:32<newsham>perhaps someone else has a more enlightening answer.
22:01:35<dmwit>(sum, or) or (or, disjoint, union) or (coproduct) is my guess
22:01:51<Heffalump>noobie: how about in mastermind?
22:01:51<newsham>noobie: how about in one of the functions that calls mmloop?
22:02:19<noobie>codeDB <- readFile "code.txt"
22:02:35<noobie>i tried to put i there and got an err
22:02:44<newsham>where did you put it?
22:02:55<Heffalump>well, show us the code and the error and perhaps we can help..
22:03:19<newsham>*sigh*
22:03:39<ddarius>ACTION suggests reading the assigned material or talking to your instructor or a tutor or someone else who is paid to educate you.
22:03:44<noobie> Syntax error in input (unexpected `<-')
22:03:50<noobie>thats the err
22:03:54<dmwit>noobie: Keep in mind that the (<-) notation must be inside a do-block, which means it has to be in a function.
22:03:59<newsham>I dont mind trying to educate you, i just refuse to do the work for you.
22:04:08<dmwit>noobie: That's pretty useless without the code that produced it.
22:04:12<newsham>if you ask questions about what you're doing and how its not working i can try to answer
22:05:56<newsham>noobie: you'd find this a lot easier if you took your big problem and broke it down into smaller problems
22:06:01<newsham>and wrote solutions for the smaller problems
22:06:02<noobie>some of persons from school as been googling me code and i don't want to post everythin
22:06:58<noobie>they r cheatin
22:07:01<newsham>you dont have to post your code. but if you dont, we might not be able to help
22:07:08<newsham>if you talk to a tutor directly you can avoid posting any code
22:07:38<ddarius>noobie: You need a tutor. You do not appear to be at the level your instructor expects you to be. Looking at your code and what you are having problems with, you have misunderstandings deeper than can be resolved with some IRCing (at least the way you are approaching it).
22:08:16<newsham>also keep in mind that we're just people here hanging out in our spare time. we're not necessarily here to help people with homework.
22:08:17<hpaste> dmwit pasted "Is there a nicer way to do this pattern?" at http://hpaste.org/4075
22:08:19<noobie>my tutor taught me nothing about this,
22:09:15<noobie>i had to learn it
22:09:27<noobie>i did that way first but i got stuck
22:10:46<noobie>u know what guys i'll jus read my course book
22:10:54<noobie>wasted a hour
22:11:01<dmwit>noobie: If you're hoping to avoid work, you came to the wrong place. Ask a good question here and the answer might be a link to a scholarly journal paper. =P
22:11:24<hpaste> ddarius annotated "Is there a nicer way to do this pattern?" with "maybe not nicer" at http://hpaste.org/4075#a1
22:11:34<dmwit>But do come back after you've read the book, and I'm sure people will be happy to try again to help you.
22:11:41<newsham>you didnt waste an hour, you used an hour to learn that there were things you didnt yet know about
22:11:44<newsham>and now you can go learn those things
22:12:11<ddarius>ACTION agrees with noobie. He wasted an hour that he could have spent reading the assigned material.
22:12:12<dmwit>ddarius: Ah, I like that a bit better.
22:12:21<dmwit>It scales to having more conditions.
22:13:03<newsham>dmwit: some cpus have instructions to do that (where a word is considered a vector of bools)
22:13:30<dmwit>I'm not expecting this MasterMind test program to be very CPU-intensive. =)
22:13:57<noobie>actually it lags
22:16:08<newsham>http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightLinear
22:16:09<lambdabot>Title: Bit Twiddling Hacks, http://tinyurl.com/3j7nq
22:16:41<dmwit>Wait, why can't I do this: "case () of { () | x = a | y = b | z = c | otherwise = d }"?
22:16:57<ddarius>dmwit: You need a ->
22:17:15<dmwit>doh
22:17:30<Saizan>mmh, with type-level lists there's no way to abstract recursion in a class and avoid the repetitive instance Foo Nil, instance Foo t => instance Foo (Cons a t), pattern?
22:17:43<ddarius>There should be.
22:18:01<ddarius>It's like encoding hofs in a logic language almost.
22:18:09<ddarius>(I think it works out a little nicer actually.)
22:18:43<Saizan>so i need a type that represent the class?
22:24:49<firefly>I think noobie did waste an hour of other people's time :/
22:24:57<firefly>ACTION likes the comp.arch solution to those problems
22:25:32<EvilTerran>Saizan, sth like: class List a l; instance List a Nil; instance List a l => List a (Cons a l); helpful?
22:26:41<newsham>firefly: thats a prespective he hasnt seen from yet
22:26:59<monochrom>What is the comp.arch solution?
22:27:04<firefly>ACTION can't quite parse that
22:27:24<EvilTerran>ACTION may not be thinking of the same problem as Saizan
22:27:25<monochrom>prespective = perspective ?
22:27:36<firefly>we have an informal competition about posting the most misleading but plausible answers to obvious homework questions.
22:27:45<monochrom>Hehe.
22:28:00<dmwit>heh
22:28:01<dmwit>yikes
22:28:02<newsham>firefly: noobie would rather complain about his wasted hour than apologize for wasting our hour
22:28:21<firefly>The best answers are so misleading that one or two classes or a few hours spent with an intro book will be enough to spot them -- but some people still use them verbatim :)
22:28:41<dmwit>Has anybody ever spotted a turned-in comp.arch answer?
22:28:51<Saizan>EvilTerran: mmh, i don't see even what the meaning of List there is
22:28:58<dmwit>(Are there any profs in comp.arch?)
22:29:04<firefly>some of the regulars sometimes teach... :)
22:29:14<firefly>yes, and chip designers.
22:29:32<monochrom>"r u gonna help or not" is the sign #haskell needs to detect and stop "helping".
22:29:40<EvilTerran>firefly: and, presumably, they're sufficiently stupid that the tutor would realise that no-one could've written it from scratch and thought it correct?
22:29:52<firefly>Andy Glew, who was one of the main P6 guys and also defined MMX and the x86 memory ordering is there.
22:30:13<firefly>They are NOT stupid. They are clearly wrong but in sophisticated ways.
22:30:23<EvilTerran>well, yes. that's what i mean
22:30:31<firefly>Mike Haertel who did work on P4 is often there.
22:31:04<firefly>Mitch Alsup (Athlon, K8 + a bunch of older cpus) is there.
22:31:16<newsham>so all the people who made the worst archs we use today? ;-)
22:31:22<firefly>Sophie Wilson (who did the ARM) has posted there occasionally.
22:31:53<firefly>The X86 is actually not that bad and P6 is fantastic implementation of it.
22:32:33<newsham>ia32 is pretty bad. they do some pretty amazing jobs with it, though.
22:32:34<firefly>There used to be some Alpha guys and a MIPS guy who "retired" from the group.
22:32:45<wli>The x86 (from a microarchitectural POV) looks fantastic until it has to interact with programs that run on it and compilers.
22:32:47<firefly>newsham: absolutely 100% wrong.
22:33:00<firefly>Too few registers, but that's about it.
22:33:10<wli>Try floating point.
22:33:23<newsham>very irregular instruction set, many instructions that are rarely useful.
22:33:28<newsham>oh yah, floating point.. heh...
22:33:56<firefly>Quite regular, actually, from 386 and onwards.
22:34:09<newsham>can you name an instruction set design that is worse than ia32?
22:34:15<newsham>firefly: wrong.
22:34:17<nominolo>interestingly though, x86 compact instruction set gives it a boost at integer performance
22:34:17<firefly>HPPA
22:34:35<firefly>IA64.
22:34:39<newsham>i've written iset models for ia32 and hppa. the ia32 one was much much much much larger
22:34:43<newsham>and more complicated
22:34:59<nominolo>compact = average bytes per instruction
22:34:59<newsham>(hppa1.1 and 2.0)
22:35:01<firefly>newsham: how and why am I wrong? References, please.
22:35:14<firefly>The IA32 set is big but that is not necessarily all that bad.
22:35:59<newsham>firefly: what sort of references are you looking for? the encoding rules in the appendices of ia32 arch ref manual vol2 are pretty large and awkward (compare re: parisc 2.0 or sparc v9)
22:36:17<firefly>does that make the architecture bad?
22:36:18<newsham>or alternately take alook at the disassembler code in binutils for ia32 vs. parisc
22:36:20<nominolo>firefly: it's hard to decode and encode, but that size of the ship takes a (mostly) constant number of transistors, so it's becoming less and less of a problem
22:36:44<nominolo>s/ship/chip/
22:36:45<newsham>its also harder to learn (more irregular)
22:36:48<firefly>I'd contend that the register windows of the sparc is a truly bad feature of the architecture, for example.
22:36:54<newsham>and harder to write backend code generators for
22:36:57<newsham>and peephole optimizers
22:36:58<firefly>Does IA32 have anything that bad?
22:37:05<nominolo>IA64 has some very nifty features
22:37:17<newsham>the instruction set of the ia32 is much more crippling for backend code generation than register windows are
22:37:21<firefly>nominolo: it has too many nifty features that don't play together well.
22:37:32<firefly>newsham: what !?!?!?!?!
22:37:35<nominolo>firefly: for example?
22:38:27<firefly>the asynchronous stack engine, which plays badly with lots of things. IA64 code basically has two stacks and needs "fat pointers" (two pointers together) for function pointers or lots of trampolines.
22:39:06<firefly>IA64 does have logic instructions for its floating-point registers. I like that.
22:39:40<nominolo>vliw is too close to the hardware, also
22:39:54<nominolo>vliw works better with JIT, though
22:40:07<wli>Register class nasties out the wazoo, floating point is at best described as "grossly irregular," immense amounts of effectively useless system state needing to be carried around (e.g. the useless crap in/around TSS's) and often even updated, etc.
22:40:08<EvilTerran>-blah
22:40:28<firefly>You can sometimes play a few tricks with logic on IEEE fp values. If you have to ship the values to the integers, operate on them, and then ship them back you usually lose more than you gain for playing those tricks. You don't have to ship back and forth on IA64.
22:41:02<firefly>wli: IA32 still has fewer kinds of fp than the PDP-11 ;)
22:41:05<newsham>ia32 memory management is the superset of all bad ideas
22:41:20<firefly>you won't say HPPA is worse?
22:41:32<newsham>not even close.
22:41:32<firefly>the many modes are a drawback on IA32, though.
22:41:51<firefly>do you prefer HPPA's segmentation over IA32's?
22:41:52<wli>My description still applies to x86-64.
22:42:09<newsham>firefly: sure. by simple virtue of his minimality in comparison.
22:42:26<newsham>s/his/its/
22:42:36<newsham>ia32 is baroquen
22:42:38<EvilTerran>-blah!
22:43:03<newsham>the only thing it has going for it is sheer popularity by virtue of long history of backwards compatibility and the windows operating system
22:43:27<ddarius>EvilTerran: You may want to use more complete sentences.
22:43:33<firefly>do I remember correctly: it takes a few of the upper bits of the 32- or 64-bit "logical address" (register + offset) and uses that to index into a table of segments and adds that value (shifted) to the value of the remaining bits and then feeds that into the page table logic?
22:43:43<EvilTerran>ddarius, it's perfectly obvious what i mean
22:43:56<ddarius>EvilTerran: To -me-
22:44:13<newsham>ff: i dont remember the exact details.
22:44:40<firefly>as far as I recall it is basically that (with a few more complications). Is that better than what the IA32 has? I don't think so.
22:44:50<wli>Tell me this: if you're going to get more instruction-level parallelism via Haskell, compare how you do it on x86-64 vs. Alpha, ARM, IA64, MIPS, PA-RISC, IBM Power, etc.
22:44:55<newsham>yes it is better. less is more.
22:45:07<newsham>its not the number of features they implemented that makes a chip great
22:45:18<newsham>its the number of features they didnt implement
22:45:23<firefly>wli: less of a need for memory barriers on IA32/AMD64 :)
22:45:24<newsham>s/chip/architecture/
22:45:41<wli>firefly: Instruction-level parallellism.
22:45:43<firefly>newsham: no, it's about their interplay.
22:46:21<firefly>instruction-level. ok, so we're talking register names, renaming...
22:46:34<alexyk>anybody knows python around here? I'm trying to do a reduce on tuples: f0 = [(1, 2, 3), (4, 5, 6)]; reduce(lambda x,y: x[2]+y[2], f0, (_,_,0)) => 'int' object is unsubscriptable... sorry for FP python, but I figure it's more likely folks here know and I'm subscribed anyways :)
22:46:49<firefly>good thing core 2 (and amd barcelona) can do some speculative out of order stuff with memory too.
22:46:51<wli>firefly: Not just that. Register classes.
22:47:00<EvilTerran>ddarius, okay, you may have a point
22:47:07<EvilTerran>given current evidence, anyway
22:48:06<dmwit>alexyk: There seems to be a pretty active #python here on FreeNode.
22:48:17<wli>firefly: The register names have to be available to the application to be used by a compiler. Insufficient registers or too many clobbers and classes and bizarre things that can't be translated effectively and the game's over.
22:48:34<firefly>a pity ghc doesn't use the real stack much. The "stack engine" of Pentium M (and core, core 2) and barcelona breaks the dependency chain of stack relative access combined with ESP modifications. I don't think that works with EBP :(
22:48:41<newsham>"To this very day, idiot software managers measure 'programmer produtivity' in terms of 'lines of code produced' whereas the notion of 'lines of code spent' is much more appropriate" -dijkstra
22:49:25<mauke>alexyk: you want to reduce to an int?
22:49:46<alexyk>mauke: yeah, it's a sum of the third element of tuples (x,y,z)
22:49:58<alexyk>mauke: works without the initializer
22:50:00<dmwit>alexyk: In any case, wouldn't it be (0,0,x[2] + y[2]) in your lambda?
22:50:22<dmwit>Or, x+y[2] or something.
22:50:34<newsham>alex: you're assunming both of your arguments are going to be tuples
22:50:35<alexyk>dmwit: works without initializer: reduce(lambda x,y: x[2]+y[2], f0) => 9
22:50:39<newsham>but you're returning a scalar value
22:50:39<dmwit>(If you choose the latter, the initializer has to be only the int, not a tuple.)
22:51:19<dmwit>alexyk: This is why you need type checking. ;-) You're mixing tuples and scalars in ways they shouldn't.
22:51:27<alexyk>int doesn't work either: reduce(lambda x,y: x[2]+y[2], f0, 0) => 'int' object is unsubscriptable
22:51:34<dmwit>x+y[2]
22:51:36<mauke>x+y[2]
22:51:41<dmwit>Or maybe x[2]+y, I'm not sure.
22:51:59<dmwit>But wouldn't this be better?
22:51:59<alexyk>oh my
22:52:02<newsham>firefly: you seem to be impressed by the implementation flash of the recent ia32 members (rightly so) and carrying that over to being impressed about the ia32 architecture itself (which is horrible)
22:52:08<dmwit>map(lambda (x,y,z): z)
22:52:11<alexyk>yeah, thats why we need types in Haskell
22:52:14<dmwit>then use "sum" or its equivalent.
22:52:18<newsham>if we had all gone to alphas a decade ago, the chips would be all the omre impressive today
22:52:30<alexyk>thx guys, sorry for the Python :)
22:52:36<newsham>by virtue of not having to jump through hoops to support a baroque architecture
22:52:48<mauke>alexyk: reduce(lambda x,y: x[2]+y[2], [(1,2,3), (4,5,6), (7,8,9)]) doesn't work either
22:53:11<alexyk>hmm
22:53:15<alexyk>works with two
22:53:18<alexyk>tuples
22:53:22<dmwit>Guess why. ;-)
22:53:36<firefly>wli: actually, we are not even close to generating semi efficient code with ghc. The current limiter seems to be branch prediction on indirect jumps (not a problem on recent X86 implementations) and the enormous amount of memory accessing going on. The X86 implementations tend to be better at handling that than the competition (they've historically had very fast L1).
22:53:40<dmwit>Hint: how many parameters does your lambda have?
22:53:46<newsham>>>> xs = [(n,n,n) for n in xrange(100)]
22:53:46<newsham>>>> reduce(lambda x,y : x + y[2], xs, 0)
22:53:47<newsham>4950
22:53:58<Japsu>reduce = foldr?
22:53:59<alexyk>dmwit: 2, so it just deduces types?
22:54:12<alexyk>reduce is a foldr with initializer optional
22:54:26<dmwit>alexyk: Do you know about the function(*args) syntax?
22:54:27<wli>newsham: Sadly, x86-64 is the last architecture ever. It'll be the last arch standing when the rest are dead and the only thing left for the rest of the history of computing.
22:54:27<ddarius>More likely a foldl I'd think
22:54:27<firefly>newsham: no. not at all. I've spent a lot of time over the last year or so reading about, thinking about, and writing about microarchitecture and the cost of implementing various macroarchitectural features.
22:54:40<newsham>ia32 is not the microarchitecture
22:54:48<dmwit>alexyk: I'm guessing that's what's happening here. It's treating your list as both initializer and reducer.
22:54:49<newsham>ia32 is the instruction set and cpu features the programmer sees
22:54:57<firefly>My target is the VAX which sadly has been much maligned. Most of the conclusions are the same for the VAX and X86.
22:55:01<alexyk>ddarius: sorry foldl
22:55:37<firefly>we will still have 8051!
22:55:37<newsham>vax is a great cisc. i love the 68k iset which is a shadow of the vaxes
22:55:48<newsham>ia32 is nothing like the vax
22:55:59<newsham>the vax instruction set *WAS* orthogonal
22:56:00<wli>VAX is good. x86 is bad. etc.
22:56:07<firefly>they are not exactly all that similar (VAX and 68K). They both look a bit like PDP11.
22:56:17<firefly>IA32 is actually a lot like the VAX.
22:56:21<alexyk>dmwit: thx, I'm happy you guys helped! very illuminating about typed FP
22:56:33<wli>No, it's nothing like the VAX.
22:56:36<dmwit>alexyk: But you really should do the equivalent of (sum . map (\(x, y, z) -> z)); it will be a lot faster and it is more orthogonal in case your datatype changes later.
22:56:41<firefly>Or rather, the problems one have to solve to make it go fast are very similar.
22:57:19<firefly>68K is not nearly as nice as I used to think -- the encoding is atrocious already in the first version of the architecture.
22:57:50<newsham>the only major faux pas in the 68k is separating A and D registers
22:57:56<alexyk>dmwit: yes, absolutely
22:57:58<wli>I think you're judging the CPU/program interface by the microarchitecture.
22:58:09<newsham>wli++ exactly what I said.
22:58:18<firefly>I tried an experiment to see how complex a decode to µops would be... it turned out to take over 200 PLA terms to figure out whether an instruction was valid or not and how big it was (you can determine this from the first word).
22:59:18<firefly>it was a single-stage solution, a smaller one could probably be found if one used a hierarchical decoding scheme.
22:59:30<firefly>(I just threw a PLA compactor at it)
22:59:59<newsham>there are only 56 instructions on the 68k
23:00:26<firefly>newsham: I think you might want to look at the binary encodings and change your mind a bit.
23:00:58<firefly>A fast implementation of the 68K needs to decode instructions fast, preferably several in parallel (or cache the decodings).
23:01:02<EvilTerran>... still talking about processors, i see.
23:01:25<firefly>In order to do that it has to distinguish between a lot more than 56 cases -- I've done the experiment.
23:01:41<goalieca>risc FTW
23:01:52<firefly>ACTION loves processors and coding to the metal
23:02:08<goalieca>ACTION like vhdl and designing the processors
23:02:14<goalieca>well fpga's anyways
23:02:16<firefly>ACTION prefers verilog
23:02:22<wli>firefly: Have you seen what compilers' code generators have to do get optimizations going on x86 and x86-64 vs. other cpus (ignoring ia64, which everyone does)?
23:02:30<EvilTerran>ACTION is quite happy with his far-removed-from-computers computing
23:03:00<wli>firefly: That's more of the sort of issue newsham and I are on about.
23:03:27<goalieca>computers are boring at the "everything is a database" level
23:03:33<firefly>errr... what do you mean by "vs. other cpus" ? They generally perform heroics (in some places) and are a bit naive (in others). That seems to be the same for all architectures.
23:03:36<newsham>or conversely, the amount of effort to semantically operate on arbitrary assembly code for said systems
23:04:04<firefly>nope, newsham seems to have bought into the "x86 is ugly, 68K and risc are kool". I know you are a bit smarter than that :)
23:04:19<newsham>ad hominem
23:04:27<wli>firefly: It's vastly different when the instruction set is a horrible mess. You can't even use the same classes of algorithms.
23:04:31<newsham>my argument does not hold water so I will call you a dummy.
23:04:55<wli>firefly: Case in point: graph coloring sucking on x86 where it does fine elsewhere.
23:05:09<firefly>too few registers, alas :(
23:05:12<goalieca>firefly, x86 is an ugly ISA but intel and amd have done amazing things underneath it.
23:05:30<newsham>I havent "bought into" anything. I've implemented systems that use instruction sets from many cpus
23:05:34<newsham>and formed my own decisions
23:05:39<newsham>opinions
23:05:46<wli>firefly: Not just that, but also register class badness, clobbers, etc.
23:06:05<firefly>I don't agree that those really are that bad.
23:06:10<wli>firefly: Moving on to floating point...
23:06:22<firefly>I don't think SP should have been a general register, though.
23:06:58<firefly>one of the fp problems was that they took too long to realize that people wanted consistency over precision.
23:07:23<firefly>Code that was 80-bit when everything was in registers and rounded to 64-bit when spilling tended to confuse people.
23:07:29<newsham>how about make the fpu a stack machine. who would want CSE?
23:07:34<firefly>They got smarter and added some rounding bits.
23:07:45<Brian`>hey, sorry to interrupt, but can I ask you a question? I'm having trouble understanding Writer monad..
23:08:07<wli>firefly: The need for something vaguely resembling a normal register file is the real problem. All the SSE bits don't really cover it. They just add more SIMD crap on.
23:08:07<ddarius>Brian`: Seeing as you are on-topic, you certainly can ask a question.
23:08:09<firefly>The fpu stack is smallish. It had a good size when they made it originally, but it should probably have been enlarged.
23:08:10<newsham>brian: this is #haskell. you have priority
23:08:19<firefly>newsham: CSE is still possible.
23:08:30<Brian`>I was looking at http://www.haskell.org/all_about_monads/examples/example17.hs and it says logMsg :: String -> Writer [Entry] ()
23:08:34<Brian`>:t Writer
23:08:40<lambdabot>forall a w. (a, w) -> Writer w a
23:09:02<Brian`>how does it work? Writer accepts (a, w) but [Entry] () is not in the form (a,w)
23:09:24<ddarius>Brian`: Writer is being used here in two different ways.
23:09:37<ddarius>Brian`: One is the -type- constructor that takes two arguments w and a
23:09:39<ddarius>:k Writer
23:09:40<lambdabot>* -> * -> *
23:09:50<ddarius>The other is the -data- constructor that takes a pair
23:09:53<ddarius>:t Writer
23:09:55<lambdabot>forall a w. (a, w) -> Writer w a
23:10:02<ddarius>@src Writer
23:10:02<lambdabot>Source not found. BOB says: You seem to have forgotten your passwd, enter another!
23:10:15<ddarius>newtype Writer w a = Writer (a,w)
23:10:21<Brian`>that's type constructor?
23:10:42<ddarius>The thing on the left is a type constructor, the thing on the right is a data constructor
23:10:53<ddarius>Compare to say, data Maybe a = Nothing | Just a
23:10:57<firefly>that's a confusing aspect of Haskell -- it still caused me to read Haskell code a bit slower up until a week ago when the same name was used for both a type and a data constructor :(
23:11:05<ddarius>Just and Nothing are data constructors, Maybe is a type constructor
23:11:23<Brian`>oh.. yeah that's confusing :(
23:11:50<ddarius>Brian`: It isn't really. Types and values live on entirely different levels so their namespaces are entirely separater.
23:11:52<newsham>Writer [Entry] () means its a writer that writes out [Entries] and results in ()
23:11:56<newsham>?type tell
23:11:58<lambdabot>forall w (m :: * -> *). (MonadWriter w m) => w -> m ()
23:12:02<wli>firefly: Also, tacking on progressively more SIMD registers is making progressively more work for the kernel in its FPU save/restore, which has degraded context switching, signal handling, and more.
23:12:19<firefly>yes, it is. They can have the same name. They probably should have shared the same namespace so people would have to use different names.
23:12:46<firefly>wli: but is it worse than the register stacks of Sparc? ;)
23:12:58<wli>firefly: I'd certainly say so.
23:13:01<Brian`>newsham, so in logMsg :: String -> Writer [Entry] (), is Writer type constructor then?
23:13:08<ddarius>firefly: -Most- people do it on purpose, so that suggests that it was the correct thing to do. Certainly having the type and value levels share namespace would be a complete mistake.
23:13:08<firefly>really?! Ok, that surprises me!
23:13:14<newsham>> runWriter (do {tell "test"; tell "this"; tell "out"; return 1})
23:13:16<lambdabot> (1,"testthisout")
23:13:18<ddarius>Brian`: That is a type...
23:13:34<firefly>ddarius: have you done usability studies on this? ;)
23:13:34<wli>firefly: You're asking the wrong person to bash SPARC.
23:14:16<firefly>with "really?!" I also sort of mean: "you probably actually have some data on this, at least anecdotally... can you share?"
23:14:16<wli>firefly: Register windowing is a fantastic hardware assist to register spilling.
23:14:24<newsham>brian: its a function which takes a string and gives you back an Writer [Entry] () action which puts the string in the writer state
23:14:26<ddarius>firefly: On what? That it'd be a mistake is clear because 1) people don't choose to work that way and 2) people would be very upset if some data constructor somewhere took up their type name.
23:14:46<newsham>when you run that action, it puts the string in the writer state and results in ()
23:15:02<newsham>> runWriter (tell "test")
23:15:02<firefly>ddarius: on how long it takes before newcomers stop being confused by the feature + on how much it slows their reading of programs down.
23:15:04<lambdabot> ((),"test")
23:15:22<firefly>You can't necessarily trust self-reported data ("oh, I like it and it doesn't slow me down").
23:15:43<firefly>We know for a fact that different fonts for example not only influence people's reading speed but also their *comprehension*.
23:15:45<ddarius>firefly: I am not in the school of making a language cater to beginners at the expense of experienced users.
23:15:54<resiak>> runWriter (tell "foo" >> tell "bar")
23:15:54<lambdabot> ((),"foobar")
23:15:59<firefly>I'd wager that this feature continues to have costs after people stop being newbies.
23:16:03<dobblego>@remember <ddarius> firefly: I am not in the school of making a language cater to beginners at the expense of experienced users.
23:16:03<lambdabot>Done.
23:16:13<ddarius>firefly: The type level -purposely- puns the value level.
23:16:28<firefly>errr... what?
23:16:50<Brian`>newsham, okay.. I'm starting to see the picture :) but I guess I need to study the codes more to fully understand :) thanks for the help
23:16:53<ddarius>firefly: The syntax for types is almost exactly a subset of the syntax of values (and there is as reason for this)
23:16:54<firefly>does "pun" have a meaning I'm not aware of? (quite likely, since I'm not a native speaker)
23:17:08<wli>firefly: It might help if you knew who I was before you asked me to bash SPARC. ;)
23:17:17<Saizan>firefly: having two intrinsicly related things have names that reminds of each other doesn't seem a bad thing
23:17:24<firefly>William Lee Irwin III, Linux hacker and much else.
23:17:34<firefly>(and mathematician)
23:17:35<Philippa_>firefly: it's not necessarily a joke, but it's otherwise the same class of thing
23:17:42<firefly>thanks.
23:17:48<wli>firefly: Maintainer (at least nominally) of which Linux kernel architecture port?
23:18:05<firefly>wli: you've worked on scalability stuff for IBM, right?
23:18:12<firefly>wli: the debian linux kernel ;)
23:18:20<firefly>(one of the maintainers, right?)
23:18:34<firefly>did you take over sparc or just 32-bit sparc?
23:18:48<wli>firefly: That's not a Linux kernel architecture port. That's a project (which I mostly just rounded up people to work on and did nothing myself).
23:19:03<wli>firefly: 32-bit SPARC
23:19:30<firefly>so you would actually know about the comparative context-switch costs :)
23:19:42<newsham>the best thing ever to come in a pizza box is a pizza
23:20:04<firefly>how does Sparc do TLS? does it sacrifice one of the GPRs or does it have an extra register squirrelled away somewhere?
23:20:29<wli>You've got to spill the stack sometime.
23:20:34<EvilTerran>sjanssen! tell us something interesting about haskell!
23:20:48<wli>firefly: It has enough GPR's to dedicate one.
23:21:29<ddarius>Okay, since EvilTerran can't seem to say it outright. EvilTerran would like you all, firefly, newsham, wli, anyone else to have this discussion on CPU architechtures in the channel #haskell-blah
23:21:33<firefly>one of those that don't participate in the windowing?
23:21:44<firefly>ok, I'll stop now.
23:21:46<newsham>ddarius: thank you. I agree completely
23:21:51<EvilTerran>thanks, ddarius :)
23:22:03<firefly>my point about using the stack more still holds, though.
23:22:14<EvilTerran>I'm afraid i suffer sometimes from being too polite/snide to be direct ;)
23:22:19<firefly>(in compiled haskell, I mean)
23:22:36<wli>firefly: The stack pointer is not unique. There are other global registers to hold such things as TLS pointers.
23:23:00<wli>firefly: So you're poking at a non-issue.
23:23:16<newsham>arguing on the internet is like running in the special olympics. even if you win, you're still a retard.
23:24:59<newsham>?src Writer tell
23:24:59<lambdabot>Source not found.
23:25:08<Saizan>so.. are gcc defined cpp constants in scope when ghc runs cpp on sources?
23:25:29<goalieca>newsham, and just like in real-life no one cares.
23:25:50<EvilTerran>Saizan, wouldn't that be fairly easy to check?
23:25:57<newsham>saizan: ghc -v foo.c shoudl tell you the answer
23:26:16<EvilTerran>although it seems likely
23:27:06<newsham>seems to me like most of the "normal" gcc defines arent there
23:27:43<EvilTerran>ACTION is still bothered by the use of cpp as a haskell preprocessor
23:27:54<ddarius>ACTION suggests m4
23:28:06<EvilTerran>as an *anything* preprocessor, even, but us haskellers in particular should be able to come up with something better
23:28:29<ddarius>EvilTerran: There are benefits of using CPP
23:28:47<newsham>oh wait i think i answered the wrong question
23:28:52<EvilTerran>other than it being generally available?
23:29:11<ddarius>EvilTerran: Often times the defines wanted are in .h files
23:32:03<EvilTerran>hmm
23:34:50<noobie>hey guys i built another function, and use within the loop and it works
23:35:46<newsham>noobie: congrats!
23:41:35<newsham>ghc -cpp -v foo.hs shows me the following -D's: __HASKELL1__=5 __GLASGOW_HASKELL__=608 __HASKELL98__ __CONCURRENT_HASKELL__ freebsd_BUILD_OS=1 x86_64_BUILD_ARCH=1 freebsd_HOST_OS=1 x86_64_HOST_ARCH=1
23:52:00<thoughtpolice>with cabal (1.2), how can you specify that an executable you're building depends on a library that's built in the same package?

Back to channel and daily index: content-negotiated html turtle