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:07:28 | <dagnachew> | anyone installed leksah on archlinux ? |
| 00:08:10 | <hydo> | dagnachew: I did a while back from darcs source. |
| 00:08:29 | <dagnachew> | hydo, what distro you use ? |
| 00:08:40 | <hydo> | dagnachew: arch |
| 00:08:41 | <dagnachew> | it complains about cabal 1.6 |
| 00:09:30 | <Berengal> | dagnachew: You need to fix the cabal file to accept Cabal >= 1.6.something instead of == |
| 00:09:54 | <hydo> | dagnachew: I'm trying to remember what I did... I think I fiddled with the cabal file. |
| 00:11:31 | <hydo> | Is there a way to get the type of a variable? I'm probably trying to do something impossible, but I'm trying to make a generic parser using guards defined as func :: String -> [a] ... and I would like to use guards against the type of a rather than case. |
| 00:11:48 | <hydo> | than a case. |
| 00:12:11 | <dibblego> | a will always be the same type |
| 00:12:27 | <mauke> | func :: String -> [a] looks useless |
| 00:12:29 | <hydo> | ah! another of my assumptions blown apart. |
| 00:12:52 | <MyCatVerbs> | hydo: No, types have to be fixed at run time. You can use algebraic data types to have a single type that can include several others as alternatives, though. |
| 00:13:27 | <Axman6> | > read "123 vghfg" :: Integer |
| 00:13:27 | <dagnachew> | hydo, |
| 00:13:28 | <lambdabot> | * Exception: Prelude.read: no parse |
| 00:13:38 | <dagnachew> | hydo, http://aur.archlinux.org/packages.php?ID=23335 |
| 00:13:42 | <MyCatVerbs> | e.g. data Foo = Bar Int | Baz String -- now if you pattern match on (Bar a), then you know that a :: Int. Or if you pattern match on (Baz a), you'll know that a :: String. |
| 00:14:24 | <hydo> | makes sense. Thanks, MyCatVerbs! |
| 00:15:28 | <MyCatVerbs> | Welcome. ^^ |
| 00:15:45 | <dagnachew> | Berengal, http://aur.archlinux.org/packages.php?ID=23335 |
| 00:17:08 | <pumpkin> | ACTION replaces roconnor's Sum 1 with Product 1 and optimizes the entire program to O(1) time |
| 00:18:35 | <ray> | pumpkin: my prelude has a Magma class :P |
| 00:18:46 | <pumpkin> | ray: yay, that makes me happy |
| 00:19:11 | <ray> | i couldn't justify anything lower (or think of anything lower) |
| 00:19:23 | <pumpkin> | I've never heard of anything lower, but who knows |
| 00:19:33 | <pumpkin> | a "closed" unary operator? :P |
| 00:19:34 | <MyCatVerbs> | There *is* nothing lower with any actual operations, surely? |
| 00:20:00 | <ray> | i don't know, but i'm going to have a partial ordering class in addition to ord |
| 00:20:44 | <MyCatVerbs> | I mean you could define, class AFunctionExists a b c where f :: a -> b -> c, and then instance (AFunctionExists a a a) => Magma a -- if it weren't for the fact that the inevitable overlapping instances would kill you. ;P |
| 00:21:14 | <pumpkin> | how about BinaryRelation ? |
| 00:21:22 | <pumpkin> | we could do with one of those |
| 00:21:34 | <MyCatVerbs> | pumpkin: isn't that just a magma, if it's closed? |
| 00:21:46 | <ray> | yeah, but what if it's open? |
| 00:22:46 | <pumpkin> | MyCatVerbs: I thought that assumed you had a function and not a general relation? |
| 00:22:54 | <pumpkin> | MyCatVerbs: but my algebra sucks, so I may be wrong :) |
| 00:23:38 | <MyCatVerbs> | ACTION checks something. |
| 00:24:02 | <MyCatVerbs> | Oh, no, I have the wrong end of the stick. |
| 00:24:27 | <MyCatVerbs> | BinaryRelation a b would be either (a -> b -> Bool) or just (a -> b). |
| 00:24:59 | <mauke> | class Relation a b |
| 00:25:18 | <MyCatVerbs> | (Depending on which of the (AFAIK isomorphic only on finite sets) ways of defining a binary relation you use.) |
| 00:26:11 | <mauke> | > 1/.5 |
| 00:26:12 | <lambdabot> | Not in scope: `/.' |
| 00:26:39 | <bogner> | is there any way to write different instances of a class for type synonyms? |
| 00:26:53 | <mauke> | bogner: I hope not |
| 00:27:10 | <MyCatVerbs> | bogner: no. You need to use newtypes if you want two identically-shaped types to have differing instances. |
| 00:27:13 | <ray> | you probably want newtypes |
| 00:27:31 | <hatds> | newtypes for typeclass instances are a pain |
| 00:27:34 | <bogner> | well, the types are in libraries |
| 00:27:48 | <hatds> | there should be a way to pass instances as arguments |
| 00:27:55 | <bogner> | and they have different meanings, but they're both ints |
| 00:28:19 | <MyCatVerbs> | hatds: there is. Use existentials. :) |
| 00:28:24 | <Cale> | hatds: But that wouldn't really be any more convenient, would it? |
| 00:28:43 | <Cale> | I suppose you could avoid unwrapping. |
| 00:28:59 | <hatds> | Cale: if you are passing many lists into a function it would be easier to pass one "ZipList" dictionary than wrap/unwrap every list |
| 00:29:00 | <Cale> | But the semantics of it are perhaps a bit tricky... |
| 00:29:30 | <MyCatVerbs> | hatds: more concretely, you're right, specifying behavoir using newtypes kind of sucks because it gets so verbose so fast. When you want to construct HOFs that take in something akin to the relevant typeclass methods as parameters, so that you can parameterise them easily, then you can construct those types using rank-2 types. |
| 00:29:55 | <pumpkin> | I really really like this proposal: http://blog.omega-prime.co.uk/?p=61 |
| 00:30:01 | <MyCatVerbs> | (nb: by "verbose" I mean "verbose by Haskell standards". Your average Java hacker probably would not even blink. ^_^) |
| 00:31:10 | <ray> | pumpkin: me too |
| 00:31:25 | <hatds> | do you really need rank-2 types? a particular Num dictionary is not universally quantified |
| 00:31:40 | <ray> | except i care less about breaking existing stuff than most people seem to |
| 00:31:49 | <MyCatVerbs> | hatds: not always, but for many types you do. |
| 00:31:55 | <hatds> | I see |
| 00:32:03 | <pumpkin> | ray: same here :P |
| 00:33:06 | <ray> | i'd like a syntax for writing instance Num a where... except Num is just an alias for a whole tower of classes, but i can implement all their methods inside one where |
| 00:33:07 | <MyCatVerbs> | hatds: I think if you wanted to pass in, say, a Monad instance, you'd have to, because return :: forall a. a -> m a. (>>=) has foralls in it too. |
| 00:33:18 | <hatds> | ah, right |
| 00:33:37 | <ray> | but i'm not so interested in a way to stay compatible with code that uses the current Num |
| 00:33:47 | <ray> | compatibility is only for wimps |
| 00:34:37 | <hatds> | rank-N isn't very nice |
| 00:34:45 | <hatds> | beyond 2 |
| 00:34:52 | <hatds> | would that ever be a problem? |
| 00:35:42 | <MyCatVerbs> | hatds: from the compiler's POV, rank-N is no harder than rank-2. Meh. |
| 00:36:15 | <pumpkin> | I guess we're keeping around the Rank2Types just for backward-compatibility? |
| 00:36:34 | <ray> | or even something crazy like.. if you have class Functor; class Functor p => Pointed p; class Pointed f => Applicative f; class Applicative m => Monad m |
| 00:36:51 | <ray> | you can define fmap et al inside an instance Monad... |
| 00:36:52 | <pumpkin> | call it Pointy |
| 00:36:53 | <pumpkin> | sounds cuter |
| 00:36:58 | <ray> | i wonder if that breaks things |
| 00:37:00 | <hatds> | what's the big to-do with higher rank types again? is it loss of type inference? |
| 00:37:03 | <ray> | i don't see how |
| 00:37:35 | <MyCatVerbs> | pumpkin: AIUI, the story went something like, "We need rank-2 types." *rank-2 types added to GHC* "Uh, y'know, it wouldn't actually be any harder to support rank-n types than it already is to support rank-2 types." "Cool!" *GHC hackers add rank-n* |
| 00:37:43 | <pumpkin> | lol |
| 00:37:58 | <pumpkin> | but meanwhile people had already started writing LANGUAGE Rank2Types so we kept that around too? |
| 00:38:00 | <MyCatVerbs> | hatds: yes, it's the loss of type inference. |
| 00:38:02 | <Zao> | "wouldn't it be cool if...", the bane of sanity. |
| 00:38:17 | <MyCatVerbs> | pumpkin: I don't know, I wasn't around for it. :3 |
| 00:38:19 | <ray> | haven't they ever heard of that 0, 1, or n rule? |
| 00:38:34 | <pumpkin> | I like the type function interpretation of associated types as presented in that recent paper |
| 00:38:38 | <MyCatVerbs> | Zao: and good, too! Sanity has no place in interesting times. :) |
| 00:38:41 | <pumpkin> | but it'd be nice if we could write type functions more explicitly |
| 00:39:08 | <pumpkin> | ray: rank-0 types! |
| 00:39:25 | <MyCatVerbs> | ray: well, this *is* the 0, 1 or n rule. 0 are monomorphic, 1 are H98 polymorphism, n is what we get after the whole song and dance has been resolved. :) |
| 00:39:36 | <MyCatVerbs> | pumpkin: rank-0 are just monomorphic types. |
| 00:39:45 | <pumpkin> | I guess :) |
| 00:40:08 | <pumpkin> | not as fun as calling them rank-0 though |
| 00:40:13 | <pumpkin> | you sound more edumacated |
| 00:40:16 | <hatds> | I find it annoy sometimes that I can't to the equivalent of (flip f) for type constructors |
| 00:40:28 | <ray> | i think "monomorphic" is word salad outside haskell channels |
| 00:40:32 | <Gracenotes> | rank-0 probably has a different meaning somewhere else |
| 00:40:35 | <pumpkin> | me too! I want to write contrafunctor instances without a newtype |
| 00:40:42 | <Gracenotes> | erm. Well, to think of one, matrices |
| 00:41:06 | <ray> | which is the extension that allows infix operators besides -> in types again? |
| 00:41:15 | <pumpkin> | TypeOperators ? |
| 00:41:21 | <pumpkin> | for things like :*: |
| 00:41:27 | <Gracenotes> | ja |
| 00:41:29 | <pumpkin> | and ~> for arrows |
| 00:41:30 | <MyCatVerbs> | hatds: you can define it as a newtype. newtype Flip f a b = f b a -- and it pretty much Just Works. |
| 00:41:59 | <ray> | yeah, makes sense |
| 00:42:00 | <MyCatVerbs> | Or even as a type synonym? I'm not sure if you can do that. *checks* |
| 00:42:03 | <ray> | i was thinking it had a crazy name |
| 00:42:06 | <pumpkin> | I thought newtype only wanted one type parameter |
| 00:43:06 | <Gracenotes> | hm? |
| 00:43:19 | <Gracenotes> | well, MyCatVerbs, you do need a constructor though |
| 00:43:22 | <pumpkin> | maybe not :) I thought the restrictions on newtype were one type parameter and one constructor |
| 00:43:25 | <MyCatVerbs> | Yes, you want to do it with a type synonym, not a newtype. |
| 00:43:33 | <MyCatVerbs> | pumpkin: you're right, my bad. |
| 00:43:47 | <Gracenotes> | type synonyms and instances, though... tricky business... |
| 00:44:09 | <Gracenotes> | o_o |
| 00:44:29 | <Gracenotes> | o_O |
| 00:44:30 | <MyCatVerbs> | { type Flip f a b = f b a; type OntoInt x = Flip (->) Int x; foo :: OntoInt [a]; foo = length; } -- Just Works, for everything you could want it to. ^_^ |
| 00:44:50 | <pumpkin> | MyCatVerbs: so I could define a ContraFunctor instance with that? |
| 00:44:55 | <MyCatVerbs> | Well, I don't think you can curry them so well, but whatever. |
| 00:45:14 | <pumpkin> | :P |
| 00:45:27 | <MyCatVerbs> | instance ContraFunctor (Flip (->) x) where cofmap f g = g . f -- ? |
| 00:45:41 | <pumpkin> | ACTION tries it out |
| 00:45:47 | <ray> | if only you could section (->) |
| 00:46:12 | <MyCatVerbs> | ray: yeah. Wasn't there a proposal for type sections at one point? Ah well, flip works too. |
| 00:46:47 | <ray> | yeah, i was looking up the type operators thing just now to see if there was any reason it didn't let you section (->) |
| 00:46:51 | <ray> | or other things |
| 00:47:06 | <defun> | what does the following ghc error message mean: "Could not find module `Control.Monad.Writer': it was found in multiple packages: monads-fd-0.0.0.0 mtl-1.1.0.2" |
| 00:47:29 | <MyCatVerbs> | Oh damn, you're not allowed to use type synonyms in instance declarations by default. |
| 00:47:32 | <ray> | hmm, i don't think that error message should start "could not find" |
| 00:48:33 | <ray> | besides that, it means the module Control.Monad.Writer is defined in both of those packages |
| 00:48:34 | <MyCatVerbs> | You've got two different modules calling themselves "Control.Monad.Writer" simultaneously, and they're fighting like cats in a trash compacto.r |
| 00:48:35 | <defun> | How could it not be found, if it says that it has been found? |
| 00:48:44 | <defun> | oh |
| 00:48:48 | <pejo> | defun, neither of the packages are listed in the dependences in the .cabal? (or you're not using --make). |
| 00:48:49 | <ray> | well, ghc sucks at error messages |
| 00:49:00 | <ray> | look at all that "possible fix: add an instance for..." stuff |
| 00:49:25 | <defun> | I used --make |
| 00:49:31 | <defun> | from ghc cli |
| 00:49:43 | <defun> | can i remove one of those packages? |
| 00:49:49 | <defun> | safely? |
| 00:50:12 | <pumpkin> | category-extras makes me feel so extreme |
| 00:50:32 | <MyCatVerbs> | ghc-pkg hide monads-fd # is probably what you want to do. |
| 00:50:32 | <pumpkin> | importing any of its modules into one of mine automatically adds a +5 l33tness score |
| 00:51:19 | <MyCatVerbs> | pumpkin: I'm confused. Are you is or are you ain't the same person as copumpkin? |
| 00:51:24 | <pumpkin> | I am :P |
| 00:51:28 | <MyCatVerbs> | Or should one of you have a goatee and the other not or something? |
| 00:51:30 | <pumpkin> | I have two computers that I use regularly |
| 00:51:32 | <defun> | MyCatVerbs: is that a ghc cli option? |
| 00:51:43 | <pumpkin> | and sometimes they're connected to IRC at the same time, so I alternate a lot |
| 00:51:47 | <pumpkin> | I can try to avoid it if it's too annoying |
| 00:51:55 | <ray> | coannoying |
| 00:52:31 | <pumpkin> | I wonder how hard it would be to add currying to type synonyms |
| 00:52:37 | <ray> | category-extras is like the giant present under the christmas tree |
| 00:53:49 | <MyCatVerbs> | defun: hrmn? That's one of the commands that's packaged with ghc. |
| 00:54:00 | <MyCatVerbs> | defun: you might have to supply --user to that, though. |
| 00:54:41 | <MyCatVerbs> | Oh hang on, that doesn't do what I was after. *grumbles* |
| 00:55:08 | <MyCatVerbs> | Anyways, you can use ghc-pkg to temporarily hide troublesome packages so that they won't be visible to the compiler any more. |
| 00:55:19 | <defun> | cool |
| 00:55:27 | <defun> | thanks |
| 00:56:15 | <MyCatVerbs> | And you can undo that change with ghc-pkg expose <packagename>, if you ever do want to. |
| 01:20:01 | <ManateeLazyCat> | I saw Yi source code write like this: [key ?>>! command] , what's the `?>>!` ? |
| 01:20:15 | <Gruppetto> | someone's idea of a good operator name |
| 01:21:19 | <MyCatVerbs> | It's the "ARGH sequencing" operator. |
| 01:21:27 | <idnar> | hahaha |
| 01:22:19 | <Nereid> | ManateeLazyCat: it's defined in Keymap/Keys.hs |
| 01:22:42 | <ManateeLazyCat> | Nereid: Thanks |
| 01:22:43 | <Nereid> | line 72 in yi 0.6.0 |
| 01:23:15 | <ManateeLazyCat> | Nereid: Yep, i have found it. :) |
| 01:26:22 | <sm> | ACTION pushes the release button and thinks, hey, how about a hackage release bot ? |
| 01:26:59 | <pumpkin> | it's already on twitter! |
| 01:27:01 | <pumpkin> | ;) |
| 01:27:18 | <sm> | bah, twitter :) |
| 01:27:49 | <Nereid> | well if RSS makes its way into lambdabot, there's http://hackage.haskell.org/packages/archive/recent.rss |
| 01:28:34 | <sm> | for now, here we go: |
| 01:28:45 | <Nereid> | lol |
| 01:29:32 | <BMeph> | ACTION will be duly impressed when a user with a fresh Platform install will be able to "cabal install yi" successfully. |
| 01:29:53 | <sm> | (if it causes trouble, please ping me) |
| 01:42:25 | <gwern> | Nereid: no point in putting rss in lb; the codebase is unmaintainable as it is. and we already have rss bots |
| 01:50:37 | <pumpkin> | @hoogle a -> [a] |
| 01:50:38 | <lambdabot> | Prelude repeat :: a -> [a] |
| 01:50:38 | <lambdabot> | Data.List repeat :: a -> [a] |
| 01:50:38 | <lambdabot> | Prelude iterate :: (a -> a) -> a -> [a] |
| 01:53:38 | <pumpkin> | > replicate 3 <=< iterate (+1) $ 2 |
| 01:53:40 | <lambdabot> | [2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12... |
| 01:54:05 | <pumpkin> | pretty useful! ;) |
| 01:55:26 | <chromakode> | hey guys, ST noob question: how would I define a "Show" instance for a mutable array in the ST monad? would an unsafeFreeze be ideal in this situation? |
| 01:55:28 | <Taggnostr> | <=<? |
| 01:56:53 | <pumpkin> | :t (<=<) |
| 01:56:55 | <lambdabot> | forall b (m :: * -> *) c a. (Monad m) => (b -> m c) -> (a -> m b) -> a -> m c |
| 01:57:07 | <dolio> | unsafeFreeze still wouldn't get your show function out of ST, if you want it to work on mutable arrays. |
| 01:57:28 | <chromakode> | dolio: so I couldn't (and wouldn't want to) make it a Show instance then? |
| 01:57:32 | <twb> | How do I say ∀ in a type signature? |
| 01:57:37 | <pumpkin> | forall |
| 01:57:39 | <chromakode> | twb: forall |
| 01:57:46 | <pumpkin> | forall a b. a -> b |
| 01:57:46 | <dolio> | No, there's no way to make a show of the right type. |
| 01:58:00 | <chromakode> | dolio: darn, thanks |
| 01:58:13 | <twb> | Illegal operator `.' in type `forall t t1 t2 . (t -> t1 -> t2 -> Distribution.Verbosity.Verbosity -> InstallDirs FilePath -> IO ())' |
| 01:58:28 | <chromakode> | I've been wrestling conceptually with the choice to use MArrays in my project -- it seems like I lose a lot by making that compromise |
| 01:58:41 | <pumpkin> | twb: maybe it doesn't like your qualified type? |
| 01:58:59 | <pumpkin> | chromakode: compared to what? |
| 01:59:05 | <chromakode> | pumpkin: IArrays |
| 01:59:20 | <twb> | pumpkin: I guess I need to pass an option to ghc –make to tell it to use them |
| 01:59:21 | <chromakode> | I'm writing a chess player in Haskell for a class on combinatoric search |
| 01:59:39 | <pumpkin> | twb: I thought it was fine with them in general, but it doesn't look like it in your case? |
| 01:59:45 | <chromakode> | to speed it up, I'm working on moving from an IArray board representation to an MArray in ST |
| 01:59:56 | <idnar> | pumpkin: isn't it an extension? |
| 02:00:05 | <pumpkin> | yeah, but I thought GHC enabled it by default all the time |
| 02:00:11 | <pumpkin> | since all the base modules use it |
| 02:00:24 | <pumpkin> | with some simple encoding involving lots of zis ? |
| 02:00:45 | <pumpkin> | preflex: zenc Control.Monad.moo |
| 02:00:47 | <preflex> | ControlziMonadzimoo |
| 02:02:03 | <Twey> | Oh, nice |
| 02:02:23 | <Twey> | Is there an inverse of zenc? |
| 02:02:27 | <pumpkin> | zdec |
| 02:02:39 | <Twey> | preflex: zdec zz |
| 02:02:39 | <preflex> | z |
| 02:02:39 | <pumpkin> | preflex: zdec ControlziMonadzimoozizizizizizi |
| 02:02:40 | <preflex> | Control.Monad.moo...... |
| 02:02:43 | <Twey> | Oho! |
| 02:03:02 | <chromakode> | Twey: that was interesting |
| 02:03:15 | <Twey> | chromakode: What's that? |
| 02:03:28 | <chromakode> | Twey: the response from zdec |
| 02:03:48 | <Twey> | GHC uses the z character for encoding of odd characters internally |
| 02:03:58 | <Twey> | zz is like \\, I guess. |
| 02:04:16 | <chromakode> | curious. |
| 02:04:16 | <inimino> | well that's ... unusual |
| 02:04:16 | <twb> | Why is it "Executable x" and not "Executable: x" in foo.cabal? |
| 02:04:21 | <pumpkin> | I remember a page with a list of the two or three things that get mangled, but I can't find it now |
| 02:04:54 | <Twey> | preflex: zenc Zoo.Zum.Zelzebar |
| 02:04:54 | <preflex> | ZZooziZZumziZZelzzebar |
| 02:05:02 | <pumpkin> | http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html |
| 02:05:10 | <Twey> | preflex: zdec Zz |
| 02:05:11 | <preflex> | Zz |
| 02:05:17 | <Twey> | preflex: zdec ZI |
| 02:05:17 | <preflex> | ZI |
| 02:05:23 | <Twey> | Hm. |
| 02:05:33 | <inimino> | preflex: zenc Zz |
| 02:05:33 | <preflex> | ZZzz |
| 02:05:37 | <pumpkin> | preflex: zdec zd |
| 02:05:38 | <preflex> | $ |
| 02:05:44 | <pumpkin> | that list seems wrong |
| 02:06:02 | <inimino> | preflex: zenc !$@#%^&*(){} |
| 02:06:03 | <preflex> | znzdz40UzhzvzczaztZLZRz7bUz7dU |
| 02:06:23 | <Twey> | Where did the zi come from, then? |
| 02:06:31 | <Twey> | preflex: zdec zd |
| 02:06:31 | <preflex> | $ |
| 02:06:42 | <Twey> | preflex disagrees with the list. |
| 02:06:58 | <inimino> | preflex: zdec zi |
| 02:06:58 | <preflex> | . |
| 02:07:05 | <Neut> | hello |
| 02:07:43 | <Neut> | If I have something, and a list of something. How can I return the number of those somethings in that list of something? |
| 02:07:58 | <inimino> | preflex: zdec z61U |
| 02:07:59 | <preflex> | a |
| 02:08:02 | <inimino> | ha |
| 02:08:23 | <inimino> | preflex: zdec z2192U |
| 02:08:23 | <preflex> | → |
| 02:08:27 | <inimino> | nice |
| 02:09:12 | <Twey> | @hoogle a -> [a] -> Int |
| 02:09:12 | <lambdabot> | Data.List elemIndex :: Eq a => a -> [a] -> Maybe Int |
| 02:09:13 | <lambdabot> | Data.List elemIndices :: Eq a => a -> [a] -> [Int] |
| 02:09:13 | <lambdabot> | Data.List intersperse :: a -> [a] -> [a] |
| 02:09:32 | <Neut> | like type, count :: a -> [a] -> Int |
| 02:09:34 | <Twey> | Neut: length (elemIndices something somethings) |
| 02:09:48 | <Twey> | Yes |
| 02:10:03 | <Twey> | count = (length .) . elemIndices |
| 02:10:12 | <Neut> | whats elemIndicies? |
| 02:10:21 | <inimino> | or filter |
| 02:10:23 | <Twey> | Finds every index of an element in a list |
| 02:10:28 | <inimino> | @ty filter |
| 02:10:29 | <lambdabot> | forall a. (a -> Bool) -> [a] -> [a] |
| 02:10:42 | <Twey> | Yeah, could do a filter on == too |
| 02:10:44 | <hatds> | I prefer filter: length . (filter (==x)) |
| 02:10:52 | <Neut> | kk tx |
| 02:11:11 | <Twey> | > elemIndices 3 [1, 2, 3, 4, 5, 3, 6, 7, 3, 8] |
| 02:11:12 | <lambdabot> | [2,5,8] |
| 02:13:34 | <Teja> | hi |
| 02:14:06 | <Teja> | can somebody please direct me a best internet resource to learn some useful haskell |
| 02:14:35 | <shachaf> | Well, "best" is a bit of a difficult word. |
| 02:14:38 | <shachaf> | @where rwh |
| 02:14:38 | <lambdabot> | is http://www.realworldhaskell.org/blog/ |
| 02:14:41 | <Teja> | I had some exp with functional programming and already went through realworld haskell |
| 02:14:44 | <shachaf> | There's that. |
| 02:14:45 | <shachaf> | Ah. |
| 02:14:47 | <Neut> | count hand rank = length.(filter(==rank)) |
| 02:14:54 | <Neut> | where does that take the hand argument though? |
| 02:15:25 | <shachaf> | Well, what do you mean by "useful"? |
| 02:15:28 | <Teja> | i want to know how haskell is being used in realworld scenarios |
| 02:15:51 | <shachaf> | The wiki has some things related to that. |
| 02:16:00 | <gwern> | Teja: do you mean you browsed through RWH or actually did the exercises and everything? |
| 02:16:03 | <Teja> | want to see how a simple library is being implemented in haskell.... lets say a simple xml parser |
| 02:16:30 | <Teja> | @gwern : Yes, most part of it.. |
| 02:16:31 | <lambdabot> | Unknown command, try @list |
| 02:16:35 | <dmwit> | Teja: Check out Hackage. There's hundreds of packages there for you to peruse. |
| 02:16:52 | <gwern> | yah. can't complain about having no real world code to look at it |
| 02:16:57 | <dmwit> | Teja: You could also check out the source of xmonad; it's nice and short and quite readable. |
| 02:17:06 | <Neut> | nvm I got it |
| 02:17:21 | <dmwit> | It's also done by some excellent Haskell coders, so it's a great place to learn by example. |
| 02:17:22 | <idnar> | @type count x xs = length (filter (==x) xs) |
| 02:17:24 | <lambdabot> | parse error on input `=' |
| 02:17:25 | <gwern> | (I didn't bust my butt cabalizing hundreds of things to see people just ignore hackage) |
| 02:17:29 | <Teja> | thanks dmwit... but is there any step by step approach |
| 02:17:30 | <idnar> | @type \x xs = length (filter (==x) xs) |
| 02:17:32 | <lambdabot> | parse error on input `=' |
| 02:17:33 | <idnar> | ugh |
| 02:17:36 | <idnar> | @type \x xs -> length (filter (==x) xs) |
| 02:17:37 | <lambdabot> | forall a. (Eq a) => a -> [a] -> Int |
| 02:17:51 | <gwern> | Teja: look at dons blog; the zipper post is particularly good |
| 02:18:08 | <Teja> | dons blog? |
| 02:18:13 | <dmwit> | ?go dons blog |
| 02:18:14 | <lambdabot> | No Result Found. |
| 02:18:18 | <dmwit> | eh? |
| 02:18:24 | <gwern> | yes, he used to have a blog, though I haven't see any updates in ages |
| 02:18:34 | <Teja> | url please |
| 02:19:02 | <gwern> | ACTION has given you enough keywords to google for |
| 02:19:31 | <Teja> | got it thanks |
| 02:20:39 | <Teja> | looks pretty interesting... thanks again gwern |
| 02:20:40 | <gwern> | there are some fascinating things on the old haskell wiki |
| 02:20:42 | <gwern> | like http://web.archive.org/web/20060304045429/www.haskell.org/hawiki/RunTimeCompilation |
| 02:20:53 | <copumpkin> | don't we have any backups other than archive.org? |
| 02:21:03 | <Neut> | http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2465#a2465 |
| 02:21:06 | <gwern> | they apparently disapeared |
| 02:21:08 | <Neut> | Can someone help me with that please. |
| 02:21:12 | <copumpkin> | that sucks |
| 02:21:24 | <copumpkin> | Neut: what's wrong? |
| 02:21:42 | <Neut> | Getting a type error |
| 02:21:44 | <Neut> | and Im not sure why |
| 02:21:52 | <copumpkin> | can you show it to us? :P |
| 02:22:56 | <Neut> | yeah i updated it |
| 02:22:57 | <MyCatVerbs> | @where hpaste |
| 02:22:57 | <lambdabot> | http://hpaste.org/ |
| 02:23:07 | <MyCatVerbs> | Oh, moonpatio. Feh. |
| 02:23:19 | <Neut> | http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2465#a2466 |
| 02:23:25 | <copumpkin> | :t countRank hand rank = length.(filter(==rank).hand) |
| 02:23:26 | <lambdabot> | parse error on input `=' |
| 02:23:32 | <dolio> | You're saying "hand" has type Hand, and then you're composing it with "filter (== rank)". |
| 02:23:32 | <copumpkin> | :t let countRank hand rank = length.(filter(==rank).hand) in countRank |
| 02:23:33 | <lambdabot> | forall a a1. (Eq a1) => (a -> [a1]) -> a1 -> a -> Int |
| 02:23:53 | <BMeph> | countRank hand rank = length(filter(==rank) hand) |
| 02:24:24 | <copumpkin> | wonderful whitespace why have you forsaken me |
| 02:24:31 | <BMeph> | Neut: I.e., those little dots do not mean what you think they mean. ;) |
| 02:24:58 | <Neut> | Hmm, |
| 02:25:05 | <Neut> | so what do I need to change to fix it? |
| 02:25:09 | <copumpkin> | take the dots out |
| 02:25:14 | <copumpkin> | and use more whitespace |
| 02:25:32 | <Neut> | Still get a type error |
| 02:25:39 | <copumpkin> | :t let countRank hand rank = length (filter (== rank) hand) in countRank |
| 02:25:40 | <lambdabot> | forall a. (Eq a) => [a] -> a -> Int |
| 02:26:06 | <copumpkin> | oh |
| 02:26:13 | <copumpkin> | you're asking for hand to be a list of Ranks |
| 02:26:18 | <copumpkin> | but also expect it to be a list of Card |
| 02:26:40 | <BMeph> | countRank hand = length . filter ((==rank) . fst) -- note the addition to the filter predicate |
| 02:27:11 | <twb> | Can someone confirm that Cabal is horribly broken? |
| 02:27:11 | <twb> | darcs get http://twb.ath.cx/tmp/tinc && darcs check --repo tinc --test |
| 02:27:48 | <BMeph> | countRank hand rank = length (filter ((==rank) . fst) hand) -- My bad, didn't notice your argument order |
| 02:27:50 | <copumpkin> | that url is a 404 here |
| 02:27:52 | <twb> | Attempting to ./Setup copy --destdir=/tmp, I get |
| 02:27:56 | <twb> | "Creating /usr/local/share/doc/foo-1/man1 (and its parents)" |
| 02:28:05 | <twb> | ...which is utterly ridiculous. |
| 02:28:15 | <Neut> | :BMeph thankyou Haskell gods |
| 02:32:31 | <wli> | What's "rank?" |
| 02:32:57 | <copumpkin> | maximal number of linearly independent cards |
| 02:32:58 | <copumpkin> | oh wait ;) |
| 02:33:00 | <Zao> | In cards, it's the value. |
| 02:33:13 | <wli> | Never mind. |
| 02:33:21 | <Neut> | On the paste I copied the type/data over' |
| 02:33:24 | <Zao> | I keep getting confused when rank is used in here. |
| 02:33:31 | <Zao> | I map it to type ranks. |
| 02:33:42 | <BMeph> | wli: Your garbage, after a weekend in the Florida sun? ;p |
| 02:34:28 | <MyCatVerbs> | wli: contra-thingumminess of foralls in type signatures. |
| 02:34:35 | <Neut> | Later guys |
| 02:37:24 | <BMeph> | ACTION thinks of extents |
| 02:38:46 | <copumpkin> | I'm gonna make a mirror of the archive.org hawiki |
| 02:38:52 | <copumpkin> | do you think that's safe? |
| 02:38:56 | <copumpkin> | (license-wise) |
| 02:42:05 | <ray> | well, who will sue you, and can you ask them not to |
| 02:42:16 | <inimino> | if it's already on archive.org... |
| 02:42:32 | <twb> | http://hackage.haskell.org/trac/hackage/ticket/555 |
| 02:42:37 | <copumpkin> | archive.org is slow as hell |
| 02:42:39 | <MyCatVerbs> | copumpkin: isn't the whole of the Haskell wiki marked with "blah blah blah under a simple permissive license"? |
| 02:43:01 | <MyCatVerbs> | So you shouldn't have any legal troubles anyways. |
| 02:43:10 | <copumpkin> | not sure if the old wiki was marked that way, but maybe |
| 02:43:42 | <MyCatVerbs> | The current one sure is. |
| 02:43:49 | <copumpkin> | yeah |
| 02:54:57 | <inimino> | as long as you're archiving it (and not basing something new on it) I don't see how you possibly could have a problem |
| 02:55:00 | <inimino> | copumpkin |
| 02:57:26 | <Vorschlagsnoten> | what could possibly go wrong |
| 02:58:09 | <roconnor> | darcs get foo doesn't actually access foo |
| 02:58:22 | <roconnor> | woah |
| 02:58:23 | <roconnor> | sorry |
| 02:58:32 | <roconnor> | apparently I was scrolled back |
| 02:59:49 | <copumpkin> | :) |
| 03:00:47 | <SamB> | roconnor: you mean it goes straight to foo/_darcs ? |
| 03:02:20 | <SamB> | (or foo/.git ;-P) |
| 03:02:56 | <copumpkin> | I wish that were .darcs instead of _darcs |
| 03:04:02 | <Berengal> | Coding is fun |
| 03:04:40 | <copumpkin> | is arithmetic coding still patented? |
| 03:05:00 | <wli> | What's wikipedia say? |
| 03:05:07 | <copumpkin> | just looking ow |
| 03:05:08 | <copumpkin> | now |
| 03:05:37 | <copumpkin> | most of them say "now expired" |
| 03:05:37 | <dolio> | @yow! |
| 03:05:38 | <lambdabot> | Hand me a pair of leather pants and a CASIO keyboard -- I'm living for today! |
| 03:05:49 | <copumpkin> | but a couple might still be going |
| 03:05:59 | <wli> | http://en.wikipedia.org/wiki/Arithmetic_coding#US_patents_on_arithmetic_coding |
| 03:06:16 | <copumpkin> | yup |
| 03:09:23 | <Cale> | Arithmetic coding seems like something which if I were working for the patent office, I would not issue a patent for on the grounds that it is too obvious. |
| 03:11:25 | <erikc> | that's sadly true of the vast majority of software patents |
| 03:11:38 | <copumpkin> | yup |
| 03:11:47 | <Cale> | "Hey guys, let's encode messages as real numbers in the interval [0,1]" "Okay, how should we do it?" "Well, we could assign each initial prefix of the message an interval corresponding to its probability of occurrence." "Oh yeah." |
| 03:11:55 | <wli> | Quite true. |
| 03:14:43 | <copumpkin> | even better, "When implemented in the manner described in G N N Martin's 1979 paper, range encoders are free from patents relating to arithmetic coding, even though they're the same thing in practice." |
| 03:15:06 | <copumpkin> | two people should implement provably equivalent algorithms and submit patents for both at the same time |
| 03:16:07 | <wli> | Computers won't matter to enough people for long enough to matter. |
| 03:17:05 | <Cale> | huh? |
| 03:26:04 | <Cale> | wli: Because the Butlerian Jihad is coming anyhow? |
| 03:26:44 | <wli> | I would not characterize the anticipated disruption as that. |
| 03:27:06 | <SamB_XP> | Cale: is that where Jeeves comes back to life and kills EVERYONE ? |
| 03:27:34 | <SamB_XP> | (though I guess he usually acts as a valet ...) |
| 03:30:15 | <dolio> | If it leads to anti-gravity belts so we no longer have to worry about getting fat and exercising while still being able to move, I'm all for it. |
| 03:32:21 | <BMeph> | ACTION measures dolio's neck for an arterial plug |
| 03:33:41 | <p_l> | ACTION would prefer nanotech-based full cyborgisation |
| 03:33:53 | <Cale> | I wonder if the Butlerian Jihad was caused by one too many spam headers saying "ENH4NCE YOUR PRESCIENCE, PUT SPICE INTO YOUR S.3.X LIFE, 100% NATURAL" |
| 03:34:53 | <dolio> | H0T B3N3 G3SSER1T TEENS READY TO SATSIFY YOUR NEEDS! |
| 03:35:01 | <p_l> | Cale: Or maybe it was spammers noticing that AIs started to overcome their schemes? :P |
| 03:36:36 | <SamB_XP> | dolio: isn't that bad for your ... uh, cardiac functions ? |
| 03:37:20 | <dolio> | Whatever. |
| 03:37:43 | <copumpkin> | ACTION is finally getting around to adding the modexp primop for Integer |
| 03:38:49 | <dolio> | It's about time! :) |
| 03:39:10 | <dolio> | Are there any others that are suitable for inclusion? |
| 03:39:16 | <copumpkin> | I might just go through the exported api for GMP's mpz and add corresponding to any functions that look interesting |
| 03:39:32 | <copumpkin> | these look nice http://gmplib.org/manual/Number-Theoretic-Functions.html#Number-Theoretic-Functions |
| 03:39:33 | <dolio> | I can't really recal what all is in there. |
| 03:39:52 | <copumpkin> | they'd help us do very fast euler problems ;) |
| 03:40:03 | <copumpkin> | http://gmplib.org/manual/Integer-Roots.html#Integer-Roots might also be handy |
| 03:40:13 | <dolio> | Well, probab_prime_p would have to be in IO. |
| 03:40:23 | <copumpkin> | yeah :) |
| 03:40:23 | <dolio> | As would nextprime, technically. |
| 03:41:06 | <copumpkin> | that wouldn't stop them from being useful though would it? |
| 03:41:15 | <dolio> | No. |
| 03:41:21 | <dolio> | @src gcd |
| 03:41:21 | <lambdabot> | gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined" |
| 03:41:21 | <lambdabot> | gcd x y = gcd' (abs x) (abs y) |
| 03:41:21 | <lambdabot> | where gcd' a 0 = a |
| 03:41:21 | <lambdabot> | gcd' a b = gcd' b (a `rem` b) |
| 03:41:43 | <dolio> | I wonder how much faster the gcd stuff is. |
| 03:42:06 | <copumpkin> | I'll stick it in and test it... if it's much faster I'll leave it in, otherwise I might as well not pollute with excessive primops |
| 03:42:28 | <copumpkin> | I wonder where I'd put a user-level API for it though |
| 03:43:02 | <dolio> | I'd go with Data.Integer, probably. |
| 03:44:02 | <dolio> | Does the integer package work cross-compiler? |
| 03:44:21 | <copumpkin> | how do you mean? |
| 03:44:50 | <dolio> | They split a fair bit of the integer stuff out of base. |
| 03:45:06 | <dolio> | It's just GHC.Integer(.*), though. |
| 03:45:25 | <dblazakis> | i've got a Data.Binary instance (Foo) and a ByteString -- what is a good way to wrte a function f :: Get [Foo] to keep grabbing Foos from the ByteString until an exception occurs? |
| 03:45:26 | <copumpkin> | oh I see |
| 03:45:33 | <copumpkin> | I was only looking at GHC.Prim so far |
| 03:45:46 | <copumpkin> | I guess I'll put the user-level interface in GHC.Integer for no |
| 03:48:18 | <copumpkin> | now I need to figure out how to write cmm :) |
| 03:48:25 | <copumpkin> | the existing macros don't help for modexp |
| 03:49:22 | <copumpkin> | lol |
| 03:49:29 | <copumpkin> | /* ToDo: this is shockingly inefficient */ |
| 03:50:04 | <dolio> | What's that from? |
| 03:50:14 | <copumpkin> | the primops.cmm |
| 03:50:27 | <copumpkin> | something to do with the threaded rts, didn't look too carefully :) |
| 03:52:07 | <Vorschlagsnoten> | whar |
| 03:54:47 | <dolio> | While you're in there, you should figure out how to determine when integer values won't be used again, and thus can be reused by gmp, instead of always allocating new ones. :) |
| 03:55:16 | <copumpkin> | ack, I'm a noob! |
| 03:55:17 | <copumpkin> | :P |
| 03:55:23 | <copumpkin> | I'll look though |
| 03:55:28 | <dmwit> | grep, I'm a noob, too! |
| 03:55:43 | <copumpkin> | looks like someone's already prepared for that |
| 03:55:48 | <copumpkin> | #define FETCH_MP_TEMP(X) \ |
| 03:55:58 | <Vorschlagsnoten> | $ ack-grep --thpppt |
| 03:56:28 | <BMeph> | who sed that ? |
| 03:56:45 | <dolio> | That wasn't a serious suggestion. You couldn't do it without uniqueness typing or some kind of analysis of the intermediate code. :) |
| 03:57:13 | <copumpkin> | oh :( |
| 03:57:29 | <copumpkin> | well, I just proved my statement, at least :) |
| 03:57:33 | <Vorschlagsnoten> | BMeph: a tr-icky decision |
| 03:58:14 | <Lemmih> | @tell dons. Yes, I read it. It is a subset of closed world grin. It seems to be half way between the implicit laziness of core and explicit thunk layout of grin. |
| 03:58:14 | <lambdabot> | Consider it noted. |
| 03:58:50 | <dolio> | Well, I suppose you could also have some kind of pool of integers or something, and only allocate them when everythign in the pool is being used, but that isn't easy either. |
| 03:59:58 | <copumpkin> | I'm trying to figure out how cmm deals with args for now |
| 04:00:13 | <copumpkin> | none of the existing gmp functions need as many args as modexp |
| 04:00:36 | <copumpkin> | I figure it's probably just the next register along |
| 04:00:43 | <copumpkin> | but I don't really know |
| 04:00:46 | <dolio> | Arguments are implicit in ghc cmm, I think. |
| 04:00:53 | <copumpkin> | yeah, they aren't explicitly listed |
| 04:00:59 | <dolio> | Unlike real cmm. |
| 04:01:00 | <copumpkin> | but the function I'm writing grabs them somehow |
| 04:01:05 | <Lemmih> | @tell dons It'll undoubtly be an improvement for GHC. For LHC there isn't much to come after, though. |
| 04:01:06 | <lambdabot> | Consider it noted. |
| 04:01:28 | <copumpkin> | there are four register arguments for the two Integers and I need a fifth for the actual exponent |
| 04:01:57 | <copumpkin> | not sure if ghc keeps passing args in registers for 5 args though |
| 04:07:08 | <copumpkin> | ACTION is trying to figure out the calling convention in GHC :P |
| 04:07:43 | <copumpkin> | http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/CallingConvention |
| 04:07:46 | <copumpkin> | what is N? :P |
| 04:08:22 | <dolio> | Heh. |
| 04:08:56 | <copumpkin> | I'd imagine it would differ from platform to platform (how many registers were available) |
| 04:09:12 | <copumpkin> | but I'm not sure how that is reflected in cmm |
| 04:09:21 | <copumpkin> | anyway, I'll idle in #ghc |
| 04:09:31 | <dolio> | Doesn't every Integer in a primop correspond to two arguments? |
| 04:09:41 | <dolio> | An Int# and a ByteArray#. |
| 04:10:05 | <copumpkin> | eah |
| 04:10:33 | <copumpkin> | but for modExp I need two Int#/ByteArray# pairs (for base and modulo) and an Int# for the exponent |
| 04:10:50 | <copumpkin> | and no primop function I can find has 5 arguments |
| 04:11:12 | <copumpkin> | the first four are definitely in R1-R4 |
| 04:11:14 | <dolio> | Oh. You're doing that modexp. |
| 04:11:38 | <copumpkin> | yeah, that looked like the hardest one :P I'll move to the other simple additions in a bit |
| 04:12:20 | <dolio> | Well, the other one requires you to find out if it passes 6 arguments in registers, doesn't it? :) |
| 04:12:52 | <copumpkin> | which one? I was going to start with the nice integer root functions :P |
| 04:13:30 | <dolio> | Wasn't there an 'b^e mod k' all Integers? Or was I seeing things. |
| 04:14:09 | <copumpkin> | oh, you're right :) |
| 04:14:22 | <copumpkin> | I missed that one |
| 04:16:22 | <SamB_XP> | copumpkin: I don't see where ELSE arguments could be passed ... |
| 04:16:29 | <copumpkin> | on the stack? |
| 04:16:37 | <SamB_XP> | the what now ? |
| 04:16:49 | <copumpkin> | http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/CallingConvention |
| 04:16:54 | <copumpkin> | don't ask me, ask them :P |
| 04:17:01 | <dolio> | Do cmm registers correspond to real registers in a way you have to worry about them? |
| 04:17:14 | <copumpkin> | I'm starting to think they don't |
| 04:17:19 | <SamB_XP> | not really, know |
| 04:17:29 | <copumpkin> | if I can refer to R4 and this code might run on i386 |
| 04:17:32 | <SamB_XP> | er. s/know/no/ |
| 04:17:37 | <copumpkin> | that's already a good indication that it's an abstraction, I guess |
| 04:18:53 | <copumpkin> | I'll try with R5 and R6 and see if it eventually crashes on me |
| 04:22:04 | <SamB_XP> | seen http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations ? |
| 04:22:14 | <SamB_XP> | there's something quite odd about the example ... |
| 04:23:04 | <SamB_XP> | copumpkin: don't you think so ? |
| 04:23:41 | <copumpkin> | hah :) |
| 04:23:43 | <dolio> | Did pumpking write this? :) |
| 04:23:46 | <dolio> | Or maybe it was me? |
| 04:23:47 | <copumpkin> | lol, no |
| 04:24:04 | <SamB_XP> | copumpkin: I guess you agree! |
| 04:24:10 | <copumpkin> | I didn't come across that page, I was looking at another page about primops |
| 04:24:32 | <SamB_XP> | since the example seems to be just what you are doing ;-P |
| 04:24:34 | <copumpkin> | but it's almost exactly what I wrote so far |
| 04:24:36 | <copumpkin> | lol |
| 04:24:56 | <SamB_XP> | one wonders why it didn't make it upstream ? |
| 04:25:15 | <copumpkin> | who knows |
| 04:25:39 | <copumpkin> | the only difference is that I called it modExp |
| 04:25:49 | <copumpkin> | I guess I should call it powmod? |
| 04:26:26 | <dolio> | You should probably put 'integer' in the name somewhere. |
| 04:26:29 | <copumpkin> | I've always thought of it as modular exponentiation |
| 04:26:30 | <SamB_XP> | dunno! |
| 04:26:31 | <copumpkin> | oh I already have |
| 04:26:41 | <copumpkin> | modExpIntegerInt# and modExpInteger# |
| 04:27:12 | <copumpkin> | I'll leave it like this and see if anyone complains |
| 04:27:43 | <dolio> | modExp is fine for my money. |
| 04:27:50 | <SamB_XP> | yeah |
| 04:27:58 | <SamB_XP> | or expMod, whatever |
| 04:28:26 | <SamB_XP> | we aren't going to expect it to give e^n % m |
| 04:28:51 | <SamB_XP> | (does that even mean something ?) |
| 04:29:02 | <SamB_XP> | ACTION goes to bed |
| 04:32:29 | <haskellnewb> | any way to make "newtype" or "data" declaration work in ghci ? |
| 04:32:41 | <dolio> | Nope. |
| 04:34:03 | <haskellnewb> | dolio thanks. so you just define all types in a file and load in ghci? |
| 04:34:53 | <dolio> | Yeah, unfortunately. |
| 04:41:47 | <roconnor> | with (,) Either () and Mu, who needs any other types? :P |
| 04:42:21 | <roconnor> | oh and (->) |
| 04:42:22 | <ivanm> | what's Mu? |
| 04:42:28 | <roconnor> | @src Mu |
| 04:42:28 | <lambdabot> | newtype Mu f = In { out :: f (Mu f) } |
| 04:42:36 | <roconnor> | ... that doesn't come in the Prelude. :( |
| 04:42:39 | <ivanm> | wtf? |
| 04:42:43 | <ivanm> | what does it do? |
| 04:42:50 | <roconnor> | @kind Mu |
| 04:42:51 | <lambdabot> | (* -> *) -> * |
| 04:42:58 | <dolio> | Fixed point. |
| 04:42:59 | <inimino> | hehe |
| 04:42:59 | <roconnor> | makes a fixedpoint type |
| 04:43:06 | <ivanm> | yeah, was thinking that |
| 04:43:22 | <sayyestolife> | when I used Common Lisp, there was a trace function who could easily trace and show different function calls (in a nice readable manner) does something similar exist for Haskell? |
| 04:43:24 | <ivanm> | roconnor: well, some actual numeric types might be helpful for efficiency purposes... |
| 04:43:56 | <roconnor> | ivanm: bah. Mu (Either ()) is good enough for anyone :P |
| 04:44:10 | <ivanm> | heh |
| 04:44:15 | <roconnor> | no one will ever need more than 640 |
| 04:44:54 | <ivanm> | roconnor: so what's the fixed point of Mu (Either ()) ? AFAICT, it's infinite... >_> |
| 04:45:07 | <dolio> | Natural numbers. |
| 04:45:25 | <ivanm> | is it? |
| 04:45:30 | <dolio> | Left (), Right (Left ()), Right (Right (Left ())), ... |
| 04:45:44 | <dolio> | Plus some Mu noise. |
| 04:45:47 | <ivanm> | oh, duh, because of how Either works |
| 04:45:51 | <roconnor> | ivanm: It could be In (Left ()) or In (Right (In (Left ())) or In (Right (In Right ... |
| 04:45:56 | <ivanm> | with Left () == zero? |
| 04:45:57 | <inimino> | march! |
| 04:46:04 | <ivanm> | inimino: lol |
| 04:46:09 | <roconnor> | ivanm: sure, why not. |
| 04:46:20 | <roconnor> | ivanm: depends on how you want to define + |
| 04:46:28 | <dolio> | My natural numbers start at 2! |
| 04:46:40 | <ivanm> | dolio: oh? |
| 04:46:50 | <ivanm> | so you don't have any identities for addition or multiplication? |
| 04:46:56 | <roconnor> | fine, if you want to be efficent: Mu (Either (Either () ())) |
| 04:47:00 | <copumpkin> | dolio: finished making my changes and writing an accessor in GHC.Integer |
| 04:47:06 | <copumpkin> | ACTION tries compiling :) |
| 04:47:09 | <dolio> | Does it work? |
| 04:47:30 | <copumpkin> | I'll tell you in a day when GHC finishes compiling :P |
| 04:47:36 | <copumpkin> | actually with -j5 it shouldn't take long |
| 04:47:46 | <dolio> | Yeah, that's the pain of doing that kind of work. |
| 04:47:50 | <dmwit> | sayyestolife: We're getting it soon! |
| 04:47:59 | <copumpkin> | dolio: going to hac phi? |
| 04:48:02 | <dolio> | roconnor: What's that? An extra value for infinity or something? |
| 04:48:02 | <dmwit> | sayyestolife: If you happen to be using GHC HEAD, you can probably get it today. |
| 04:48:10 | <dolio> | Wasn't planning on it. |
| 04:48:30 | <roconnor> | Either () () is Bool |
| 04:48:37 | <dolio> | Oh, right. |
| 04:48:53 | <dmwit> | sayyestolife: Well, we're getting stack traces soon, anyway; not sure if that's what you were actually asking for. |
| 04:49:26 | <dmwit> | sayyestolife: In the meantime, you can use Debug.Trace.trace to print debug messages, but it's usually considered a little bit dirty. |
| 04:49:40 | <roconnor> | hmm |
| 04:49:41 | <ivanm> | @src trace |
| 04:49:42 | <lambdabot> | trace string expr = unsafePerformIO $ do |
| 04:49:42 | <lambdabot> | hPutStrLn stderr string |
| 04:49:42 | <lambdabot> | return expr |
| 04:50:01 | <ivanm> | dmwit: I'd say more than just a "little bit" ;-) |
| 04:50:09 | <dmwit> | Not really. |
| 04:50:30 | <dmwit> | You'd have to do some pointer munging or something to rise above "a little bit dirty." =) |
| 04:50:47 | <roconnor> | dolio: am I missing the S and K type combinators? |
| 04:51:14 | <dolio> | Possibly. |
| 04:51:30 | <roconnor> | I don't think I can't make data Dom = Dom (Dom -> Dom) |
| 04:51:30 | <ivanm> | dmwit: heh |
| 04:52:02 | <dmwit> | newtype Join f a = f a a |
| 04:52:14 | <dmwit> | Dom = Mu (Join (->)) |
| 04:52:22 | <roconnor> | now do Const |
| 04:52:39 | <copumpkin> | isn't Const a phantom type? |
| 04:52:49 | <roconnor> | ya |
| 04:52:55 | <copumpkin> | oh, I guess you can't get rid of it? |
| 04:53:20 | <Berengal> | What, are we implementing LC in the type system now? |
| 04:53:32 | <roconnor> | and then do flip |
| 04:53:47 | <roconnor> | Berengal: we need to. |
| 04:54:05 | <dolio> | Well, if you want to have type combinators for all the stuff you can write with haskell data declarations, you pretty much need LC. |
| 04:54:07 | <roconnor> | Berengal: so we can get all our types in ghci. |
| 04:54:27 | <roconnor> | but I wonder if we can just define one Dom type |
| 04:54:51 | <roconnor> | and then some how program in an untyped manner |
| 04:54:52 | <Berengal> | roconnor: So we're doing this to overcome the lack of type definitions in ghci? |
| 04:54:55 | <dolio> | (), (,), Either, Mu and (->) is only enough for simple types, I think. |
| 04:55:11 | <roconnor> | Berengal: yep |
| 04:55:15 | <Berengal> | I love this channel... |
| 04:55:27 | <ivanm> | ahhh.... that makes more sense then |
| 04:55:39 | <ivanm> | then again... why do you want to be able to define types in ghci? |
| 04:56:24 | <dolio> | Strictly speaking it isn't even enough for some simple types, I guess. |
| 04:56:43 | <ivanm> | roconnor: hmmm... with your quote in HWN, why did you want to make something as slow as Python? |
| 04:57:06 | <dmwit> | > ( ) |
| 04:57:07 | <lambdabot> | () |
| 04:57:08 | <dolio> | 'newtype Foo = Foo (Maybe (Maybe Foo))' needs composition for 'Mu (Maybe :. Maybe)'. |
| 04:59:00 | <roconnor> | ivanm: http://www.reddit.com/r/programming/comments/8mmcu/i_tried_to_translate_the_ironpython_code_to/ |
| 04:59:15 | <copumpkin> | I'm still tempted to try to add inline primops for all the SSEn instructions (with suitable changes to the x86(_64) codegen |
| 04:59:36 | <dolio> | Also, Mu (Either (Either () ())) isn't binary naturals. |
| 04:59:40 | <copumpkin> | although maybe it would be better to try to abstract it to different simd archs |
| 05:00:06 | <roconnor> | dolio: huh? |
| 05:00:16 | <dolio> | Mu (Either () :. (,) (Either () ())) is. |
| 05:00:26 | <roconnor> | oh |
| 05:00:33 | <copumpkin> | what's :. ? |
| 05:00:37 | <dolio> | Composition. |
| 05:00:50 | <copumpkin> | is it possible to write that? |
| 05:00:52 | <roconnor> | aww |
| 05:00:57 | <roconnor> | we need a compose combinator too |
| 05:01:03 | <roconnor> | I was afraid of that |
| 05:01:07 | <dolio> | Yeah. |
| 05:02:21 | <roconnor> | can we encode everything in data Dom = Dom (Dom -> Dom) ? |
| 05:02:34 | <roconnor> | Does Dana Scott have something to say about this? |
| 05:02:43 | <copumpkin> | is that fix in typeland? |
| 05:02:57 | <dmwit> | No, it's "Dynamic" in typeland. |
| 05:02:57 | <roconnor> | copumpkin: no Mu is fix in typeland |
| 05:03:11 | <dmwit> | Not sure what all this Dom naming is about. =P |
| 05:03:12 | <copumpkin> | hmm, Dynamic? |
| 05:03:19 | <roconnor> | Domain |
| 05:03:40 | <dmwit> | copumpkin: It's the type of an untyped lambda-calculus term. |
| 05:03:47 | <copumpkin> | ah |
| 05:04:07 | <copumpkin> | so we'd be able to write loop in terms of it? |
| 05:04:09 | <roconnor> | ah right |
| 05:04:36 | <roconnor> | \a b. a becomes Dom (\a -> Dom (\b -> a)) |
| 05:05:21 | <ivanm> | roconnor: so was that yet another case of ghc turning horribly inefficient code into rather efficient code? |
| 05:05:24 | <hatds> | wow guys, I'm lol'ing |
| 05:05:29 | <hatds> | gnight |
| 05:06:04 | <dmwit> | Dom (\f -> Dom (\x -> (unDom ((unDom f) (unDom x x)) ((unDom f) (unDom x x))))) -- omega! O_o |
| 05:06:09 | <roconnor> | ivanm: yep. I tried, I really tried. |
| 05:06:12 | <copumpkin> | nice :) |
| 05:06:23 | <roconnor> | dmwit: sorry, that is the y combinator |
| 05:06:28 | <ivanm> | roconnor: heh |
| 05:06:28 | <ivanm> | harrop's comment was a bit weird though... |
| 05:06:30 | <roconnor> | omega is Y id. |
| 05:06:31 | <dmwit> | ultra fail |
| 05:06:40 | <dmwit> | And I call my self a PL guy. |
| 05:06:50 | <copumpkin> | aw |
| 05:06:57 | <roconnor> | ivanm: oh? |
| 05:07:14 | <roconnor> | jdh30? |
| 05:07:17 | <copumpkin> | yup |
| 05:07:21 | <ivanm> | roconnor: yup |
| 05:07:28 | <roconnor> | I think it was a fair comment. |
| 05:07:36 | <roconnor> | I neither voted it up nor down |
| 05:07:57 | <SubStack> | http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2469#a2469 |
| 05:08:00 | <copumpkin> | it was strange in that it wasn't unpleasant :P |
| 05:08:05 | <copumpkin> | very uncharacteristic of him |
| 05:08:08 | <roconnor> | ah |
| 05:08:08 | <ivanm> | copumpkin: yeah |
| 05:08:24 | <ivanm> | he wasn't actually bashing anyone |
| 05:08:34 | <copumpkin> | I mean he did say the famous "real software" thing |
| 05:08:34 | <ivanm> | just the pseudo-benchmark being used |
| 05:08:36 | <copumpkin> | but that's about it |
| 05:09:14 | <roconnor> | ivanm: I really thought I was doing a fair translation to Haskell, but then GHC had to go screw it up by making it exponentially more efficient. |
| 05:09:20 | <copumpkin> | I think thoughtpolice was so terrified by trying to get a registered x86_64 osx build that he ran away |
| 05:09:22 | <SubStack> | it seems like there's some higher-level function I should be familiar with there |
| 05:09:23 | <roconnor> | my fault for using the Writer Monad. |
| 05:09:25 | <ivanm> | roconnor: lol |
| 05:09:28 | <roconnor> | first time. |
| 05:09:31 | <SubStack> | or pattern or what-have-you |
| 05:10:15 | <copumpkin> | ACTION urges his GHC build to finish |
| 05:11:23 | <copumpkin> | omg it's me |
| 05:11:46 | <ivanm> | *sigh* |
| 05:11:54 | <SubStack> | ACTION boggles at the multi-pumpkins |
| 05:12:02 | <copumpkin> | ACTION hides from ivanm |
| 05:12:04 | <dmwit> | And with the same netmask, too! |
| 05:12:28 | <roconnor> | /join #cohaskell |
| 05:12:36 | <dolio> | flip (-) = subtract |
| 05:12:43 | <ivanm> | copumpkin: don't worry, I'm not a big fan of pumpkins |
| 05:12:49 | <ivanm> | *of eating pumpkins |
| 05:13:09 | <dolio> | > map length ["flip (-)", "subtract"] |
| 05:13:10 | <lambdabot> | [8,8] |
| 05:13:12 | <ivanm> | and I'm not from North America, so I don't butcher them near the end of october either |
| 05:13:27 | <roconnor> | @src subtract |
| 05:13:27 | <lambdabot> | subtract x y = y - x |
| 05:13:28 | <copumpkin> | I don't either! |
| 05:13:47 | <SubStack> | pumpkins don't even exist! |
| 05:14:02 | <roconnor> | > length . ["flip (-)", "subtract"] |
| 05:14:03 | <lambdabot> | Couldn't match expected type `a -> [a1]' |
| 05:14:20 | <SubStack> | nifty @ subtract |
| 05:14:44 | <SubStack> | I think I've heard that before even |
| 05:14:48 | <dmwit> | > map length ["map (flip (-))", "map subtract"] |
| 05:14:49 | <lambdabot> | [14,12] |
| 05:15:22 | <dmwit> | (So "subtract" can still be shorter in some cases, even though on its own it is as long as "flip (-)".) |
| 05:15:46 | <dolio> | It can? |
| 05:15:51 | <roconnor> | > map length ["map$flip (-)", "map subtract"] |
| 05:15:52 | <dolio> | Oh, right. |
| 05:15:53 | <lambdabot> | [12,12] |
| 05:16:11 | <roconnor> | > map length ["map$flip(-)", "map subtract"] |
| 05:16:12 | <lambdabot> | [11,12] |
| 05:16:32 | <dmwit> | > map length ["map (flip (-)) xs", "map subtract xs"] |
| 05:16:33 | <lambdabot> | [17,15] |
| 05:16:36 | <Berengal> | Not to mention no parenthesis in subtract |
| 05:16:40 | <dolio> | map subtract isn't the type of thing you're likely to see. |
| 05:16:44 | <dmwit> | > map length ["map(flip(-))xs", "map subtract xs"] |
| 05:16:45 | <lambdabot> | [14,15] |
| 05:17:01 | <dolio> | More likely "map (subtract 1)". |
| 05:17:17 | <dmwit> | ACTION posits that " subtract " is nevertheless more readable than "(flip(-))", and that any sane person would be putting the spaces in anyway |
| 05:17:28 | <dmwit> | dolio: true |
| 05:17:39 | <dolio> | It is more readable, though. |
| 05:17:50 | <Berengal> | What annoys me is that you can't map (-1) |
| 05:18:02 | <dmwit> | Yep, that was probably one of the less good decisions. |
| 05:18:16 | <dmwit> | (And is the direct motivation for defining subtract.) |
| 05:18:24 | <Berengal> | I would've gone for ~1 had I been designing the language, but that might be just me |
| 05:18:32 | <dmwit> | ~1 is a pattern |
| 05:18:35 | <dolio> | Coming up with an alternate negative number notation would probably be good. |
| 05:18:45 | <dolio> | Although the current negative is pretty magic. |
| 05:18:45 | <dmwit> | > let ~1 = 1 in 32 |
| 05:18:47 | <lambdabot> | 32 |
| 05:18:50 | <ivanm> | Berengal: map pred ;-) |
| 05:18:51 | <Berengal> | _1 then |
| 05:18:53 | <dolio> | > let n = 52 in -n |
| 05:18:55 | <lambdabot> | -52 |
| 05:19:11 | <ivanm> | Berengal: so you want to re-define mathematics then? :o |
| 05:19:12 | <ivanm> | ;-) |
| 05:19:23 | <copumpkin> | > map (+(-1)) [1..10] |
| 05:19:24 | <lambdabot> | [0,1,2,3,4,5,6,7,8,9] |
| 05:19:25 | <outchanter> | map (-1+) |
| 05:19:38 | <copumpkin> | nicer :) |
| 05:19:39 | <dolio> | Also, I frequently got bit by the fact that "-n `mod` k" parses as "-(n `mod` k)" in the past. |
| 05:19:41 | <dmwit> | > map (+ -1) [1..10] -- hmmm |
| 05:19:42 | <lambdabot> | The operator `+' [infixl 6] of a section |
| 05:19:42 | <lambdabot> | must have lower prece... |
| 05:19:48 | <Berengal> | ivanm: Mathematics got it wrong when they chose the same symbol for negation and subtraction |
| 05:19:55 | <copumpkin> | implicit 0! |
| 05:20:03 | <ivanm> | exactly |
| 05:20:12 | <roconnor> | I would just redesign the language not to have numbers. They are stupid and evil anyways. |
| 05:20:27 | <dmwit> | > let (+-) = (-) in map (+-1) [1..10] |
| 05:20:28 | <lambdabot> | [0,1,2,3,4,5,6,7,8,9] |
| 05:20:28 | <ivanm> | also, physics got it wrong when it said that electricity was the flow of positive charges... |
| 05:20:33 | <Berengal> | roconnor: Who needs numbers when you've got lambdas? |
| 05:20:34 | <outchanter> | > map (-1+) [1..10] |
| 05:20:36 | <lambdabot> | [0,1,2,3,4,5,6,7,8,9] |
| 05:20:57 | <dmwit> | outchanter: Mine is more ridiculous. ;-) |
| 05:21:12 | <inimino> | lambdas can be used to implement numerals, they'll have to go too. |
| 05:21:34 | <roconnor> | Berengal: more that programing is mainly about manipulating other structures, like lists and such. |
| 05:21:56 | <Berengal> | inimino: Let's replace them with lambadas! |
| 05:22:29 | <inimino> | actually defining a language where constants are not allowed, and have to provided as a table at runtime would be pretty interesting |
| 05:23:09 | <Berengal> | inimino: Implicit top-level reader monad? |
| 05:23:12 | <dolio> | Lambda expressions are constants (so to speak). |
| 05:23:31 | <inimino> | Berengal: heh, something like that |
| 05:23:34 | <dolio> | As much as numerals. |
| 05:23:55 | <Berengal> | dolio: A only if it doesn't contain bound variables, no? |
| 05:23:59 | <inimino> | maybe with names though |
| 05:24:12 | <dolio> | Well, yes. 'Literal' is probably a better word. |
| 05:24:27 | <dmwit> | inimino: I don't think there's anything particularly interesting in going down that path. Everything sort of "just works." |
| 05:24:33 | <copumpkin> | boo, of course it isn't as simple as it should be |
| 05:24:57 | <inimino> | dolio: yes, but I meant specifically numbers and strings |
| 05:25:07 | <dmwit> | inimino: It's actually the model that many languages use... including Haskell, if you think of the Prelude as that top-level lookup table (with names ;-). |
| 05:25:10 | <inimino> | dmwit: yeah, it just works |
| 05:25:41 | <Berengal> | dmwit: Number literals aren't defined in the Prelude, are they? |
| 05:25:53 | <dmwit> | No, I suppose not. |
| 05:25:57 | <inimino> | dmwit: but if you think about things like localization its just a slightly different perspective |
| 05:26:06 | <dolio> | GHC actually gives names to various literals you might have in your code. |
| 05:26:15 | <roconnor> | Berengal: for example consider my original code: |
| 05:26:17 | <roconnor> | [ map fst y i <- [0..], y <- replicateM i menu, sum (map snd y) == 1505 ] |
| 05:26:21 | <inimino> | the Prelude actually isn't passed in at runtime, so it's not quite like that |
| 05:26:31 | <dolio> | If you have something like "foo = bar 0" it might translate that into "z = 0 ; foo = bar z". |
| 05:26:37 | <roconnor> | Much better written as: |
| 05:26:39 | <roconnor> | [ map fst y | y <- concat (iterate (liftM2 (:) menu) [[]]), sum (map snd y) == 1505] |
| 05:26:46 | <roconnor> | And the numbers are gone! |
| 05:26:59 | <roconnor> | except for sum and 1505 |
| 05:27:07 | <roconnor> | but those are still dumb. |
| 05:27:12 | <dmwit> | menu? |
| 05:27:15 | <dmwit> | oh |
| 05:27:34 | <roconnor> | menu :: [(String,Integer)] |
| 05:27:41 | <copumpkin> | ACTION hopes he made all the necessary changes and that the new build system has its dependencies right :P |
| 05:27:58 | <Berengal> | Ah, xkcd' |
| 05:28:11 | <roconnor> | http://www.haskell.org/pipermail/haskell-cafe/2007-July/028262.html |
| 05:28:19 | <roconnor> | ``Shouldn't we stay away from integer indices on lists?'' |
| 05:28:37 | <roconnor> | Henning is absolutely right. |
| 05:28:50 | <roconnor> | Integers have corrupted my programming style. |
| 05:28:57 | <inimino> | against "!!"? |
| 05:28:58 | <copumpkin> | Integers are awesome |
| 05:29:29 | <copumpkin> | lol, segfault in ghc build |
| 05:29:33 | <dolio> | dons' code doesn't use integer indices on lists. |
| 05:29:35 | <ivanm> | heh |
| 05:29:51 | <roconnor> | copumpkin: Integers are not lazy, and they are always leaving large piles of unevaluted thunks laying around. |
| 05:29:58 | <ManateeLazyCat> | How to element of list with given `index`? |
| 05:30:15 | <copumpkin> | roconnor: unevaluated thunks? why? |
| 05:30:31 | <ivanm> | roconnor: but if it used Ints it would be OK? |
| 05:30:33 | <roconnor> | ManateeLazyCat: your question suggests you are looking at your problem wrong. :) |
| 05:30:43 | <roconnor> | ivanm: Ints are even worse |
| 05:30:46 | <ivanm> | :o |
| 05:30:56 | <roconnor> | @src length |
| 05:30:56 | <lambdabot> | Source not found. That's something I cannot allow to happen. |
| 05:30:58 | <copumpkin> | ACTION sighs and makes GHC from scratch |
| 05:31:00 | <ivanm> | I thought Int# was the non-lazy one... |
| 05:31:09 | <roconnor> | huh? |
| 05:31:16 | <roconnor> | @src head |
| 05:31:16 | <lambdabot> | head (x:_) = x |
| 05:31:16 | <lambdabot> | head [] = undefined |
| 05:31:22 | <roconnor> | @src length |
| 05:31:22 | <lambdabot> | Source not found. You type like i drive. |
| 05:31:33 | <Berengal> | @src genericLength |
| 05:31:33 | <lambdabot> | genericLength [] = 0 |
| 05:31:33 | <lambdabot> | genericLength (_:l) = 1 + genericLength l |
| 05:31:44 | <Berengal> | length = genericLength + MR |
| 05:31:47 | <copumpkin> | you mean lazy in the (length [0..]) > 3 == True ? |
| 05:31:53 | <roconnor> | copumpkin: ^^ example of thunks laying around. |
| 05:31:54 | <copumpkin> | genericLength I meant |
| 05:32:01 | <copumpkin> | hmm |
| 05:32:16 | <ivanm> | roconnor: because it isn't forced you mean? |
| 05:32:27 | <copumpkin> | @src length |
| 05:32:28 | <lambdabot> | Source not found. And you call yourself a Rocket Scientist! |
| 05:32:32 | <roconnor> | ivanm: or because they are not lazy |
| 05:32:34 | <ManateeLazyCat> | roconnor: I can use `drop` and `head` get element value, but i find exist function do this work. |
| 05:32:41 | <Berengal> | or length = foldl (const . (+1)) 0 |
| 05:32:42 | <copumpkin> | roconnor: how does Int do better? |
| 05:32:48 | <roconnor> | > (length [0..]) > (3::Nat) |
| 05:32:48 | <copumpkin> | foldl' would be better? |
| 05:32:49 | <lambdabot> | Not in scope: type constructor or class `Nat' |
| 05:32:53 | <roconnor> | > (length [0..]) > (3::Natural) |
| 05:32:53 | <lambdabot> | Couldn't match expected type `Int' against inferred type `Natural' |
| 05:32:55 | <ivanm> | copumpkin: he said they weren't... |
| 05:33:01 | <roconnor> | > (genericLength [0..]) > (3::Natural) |
| 05:33:01 | <dmwit> | ManateeLazyCat: (!!) will do it, but you should really think hard before you use it |
| 05:33:02 | <lambdabot> | True |
| 05:33:08 | <roconnor> | see, much better |
| 05:33:11 | <copumpkin> | yeah :) |
| 05:33:13 | <copumpkin> | but much slower |
| 05:33:15 | <dmwit> | ManateeLazyCat: Using (!!) is a code smell. |
| 05:33:26 | <copumpkin> | for most finite situations :P |
| 05:33:35 | <roconnor> | copumpkin: Haskell has no time for your operational semantics nonsense. |
| 05:33:39 | <copumpkin> | lol |
| 05:33:47 | <copumpkin> | and integers will have fast modular exponentiation soon! |
| 05:33:51 | <dmwit> | > zip [0..] [0..2] == [0..3] -- equivalent |
| 05:33:52 | <lambdabot> | No instance for (Enum (t, t1)) |
| 05:33:52 | <lambdabot> | arising from the arithmetic seque... |
| 05:34:06 | <dmwit> | > zipWith const [0..3] [0..] == [0..3] -- equivalent |
| 05:34:07 | <lambdabot> | True |
| 05:34:17 | <ManateeLazyCat> | dmwit: Thanks, (!!) is i want. |
| 05:34:24 | <copumpkin> | ManateeLazyCat: probably not, though |
| 05:34:35 | <ManateeLazyCat> | copumpkin: ? |
| 05:34:54 | <dmwit> | ManateeLazyCat: As several of us have said: if you are using (!!), you are probably making a mistake. |
| 05:34:56 | <roconnor> | ManateeLazyCat: I'm not sure I understood your `drop` and `head` comment. |
| 05:35:11 | <Berengal> | (!!) = (head.).drop |
| 05:35:41 | <roconnor> | ManateeLazyCat: oh were you asking a question about finding an index? I thought you were making a comment about my comments. |
| 05:36:00 | <ManateeLazyCat> | roconnor: Yep, |
| 05:36:22 | <copumpkin> | there isn't a modExp for Int in the standard library anywhere is there? |
| 05:36:23 | <ManateeLazyCat> | dmwit: I think not, i just give index value from list. |
| 05:36:25 | <copumpkin> | @src Integer |
| 05:36:25 | <lambdabot> | data Integer = S# Int# |
| 05:36:25 | <lambdabot> | | J# Int# ByteArray# |
| 05:36:29 | <dmwit> | > let minLength n xs = let ys = replicate n () in zipWith const ys xs == ys in minLength 2 [0..] |
| 05:36:30 | <lambdabot> | True |
| 05:36:30 | <Gracenotes> | Berengal: except it's safer |
| 05:36:44 | <Berengal> | Gracenotes: Safer how? |
| 05:36:57 | <Gracenotes> | well. I guess the head actually takes care of that |
| 05:37:04 | <copumpkin> | takes care of making it unsafe? :P |
| 05:37:09 | <Gracenotes> | quite |
| 05:37:13 | <copumpkin> | :) |
| 05:37:30 | <Gracenotes> | but drop is pretty safe, by itself certainly |
| 05:37:35 | <roconnor> | > [0..]!!(-1) |
| 05:37:37 | <lambdabot> | * Exception: Prelude.(!!): negative index |
| 05:37:44 | <Gracenotes> | sort of a cautious way to check out indexing |
| 05:37:50 | <copumpkin> | if I had an army of willing haskell codemonkies, I'd get them to get GHC to build with no warnings... it's quite distressing currently |
| 05:37:51 | <Gracenotes> | oh. hm. |
| 05:37:54 | <roconnor> | > ((head.).drop)(-1)[0..] |
| 05:37:55 | <lambdabot> | 0 |
| 05:38:02 | <roconnor> | meh |
| 05:38:04 | <roconnor> | close enough |
| 05:38:12 | <ManateeLazyCat> | (!!) not check list length and index before get value |
| 05:38:19 | <copumpkin> | I should hope not |
| 05:38:20 | <roconnor> | drop (-1) should probably fail anyways. |
| 05:38:33 | <Gracenotes> | or get the last element of the list :P |
| 05:38:38 | <roconnor> | oh god |
| 05:38:39 | <dmwit> | roconnor: No, it should add an element to the list! |
| 05:38:40 | <copumpkin> | ooh, ruby style |
| 05:38:59 | <roconnor> | drop (-1) [0..] == [(-1)..] |
| 05:38:59 | <dmwit> | drop (-2) [0..] = [-2..] |
| 05:39:02 | <dmwit> | yep |
| 05:39:12 | <ManateeLazyCat> | Have a function that type is "[a] -> Int -> Maybe a"? |
| 05:39:22 | <roconnor> | @hoogle [a] -> Int -> Maybe a |
| 05:39:23 | <lambdabot> | Prelude (!!) :: [a] -> Int -> a |
| 05:39:23 | <lambdabot> | Data.List (!!) :: [a] -> Int -> a |
| 05:39:23 | <lambdabot> | Data.List genericIndex :: Integral a => [b] -> a -> b |
| 05:39:26 | <Gracenotes> | it would probably be made of drop, though |
| 05:39:27 | <dmwit> | :t \n -> take 1 . drop n |
| 05:39:28 | <lambdabot> | forall a. Int -> [a] -> [a] |
| 05:39:35 | <copumpkin> | you'd want a listToMaybe |
| 05:39:40 | <dmwit> | :t \n -> listToMaybe . drop n |
| 05:39:41 | <lambdabot> | forall a. Int -> [a] -> Maybe a |
| 05:39:53 | <roconnor> | @hoogle+ |
| 05:39:53 | <lambdabot> | Data.List elemIndex :: Eq a => a -> [a] -> Maybe Int |
| 05:39:53 | <lambdabot> | Prelude const :: a -> b -> a |
| 05:39:53 | <lambdabot> | Data.Function const :: a -> b -> a |
| 05:39:54 | <Gracenotes> | even simple: case drop n xs of { [] -> Nothing; (x:_) -> Just x } |
| 05:40:04 | <roconnor> | hmm |
| 05:40:08 | <roconnor> | I guess there isn't one |
| 05:40:12 | <dmwit> | Gracenotes: Boo, use the existing listToMaybe for that. |
| 05:40:34 | <Gracenotes> | and import a module??? ARE YOU CRAZY? Nobody imports modules!! |
| 05:40:54 | <dmwit> | ACTION usually has 15-20 lines in his boilerplate {{{ }}} section |
| 05:41:13 | <dmwit> | Sometimes as much as a third of my program! O_o |
| 05:41:17 | <roconnor> | ManateeLazyCat: ``stay away from integer indices on lists |
| 05:41:29 | <Berengal> | Actually, I've been finding it kind of freaky that the import declarations in haskell aren't too far off from enterprise java... |
| 05:41:40 | <Gracenotes> | although again, the above doesn't make much sense for negative indices |
| 05:42:03 | <Gracenotes> | quizas, quizas, quizas |
| 05:42:18 | <dmwit> | mInd n xs | n < 0 = Nothing | otherwise = listToMaybe . drop n $ xs |
| 05:42:36 | <jeffwheeler> | Berengal: it's the cases where there's repeated imports, one qualified, and one unqualified but restricted to only certain identifiers, that makes me worry about the import design |
| 05:42:43 | <copumpkin> | Return non-zero if op is a perfect power, i.e., if there exist integers a and b, with b>1, such that op equals a raised to the power b. |
| 05:42:53 | <dmwit> | fRacturedmInd n xs | even n = n `div` 2 | otherwise = 3 * n + 1 |
| 05:43:06 | <roconnor> | jeffwheeler: I do that a quite a bit |
| 05:43:08 | <Gracenotes> | c-c-c-c-collatz breaker |
| 05:43:26 | <jeffwheeler> | roconnor: yeah, it seems very strange to me |
| 05:43:42 | <roconnor> | I like my operators unqualified. |
| 05:43:45 | <ManateeLazyCat> | roconnor: In factr, i want find some element form `Data.Set`, so i use `toList` transform `Set` to `List`, then find index. |
| 05:43:57 | <dmwit> | eh? |
| 05:44:13 | <dmwit> | :t Data.Set.member |
| 05:44:14 | <lambdabot> | forall a. (Ord a) => a -> S.Set a -> Bool |
| 05:44:15 | <jeffwheeler> | Also commonly used, stuff from Data.List and similar is often re-exported. |
| 05:44:53 | <roconnor> | jeffwheeler: oh? |
| 05:44:56 | <dmwit> | :t (filter .) . Data.Set.toList |
| 05:44:58 | <Berengal> | > let loeb x = fmap (\a -> a (loeb x)) x in loeb $ const 0:const 1:[(+1).(!!(if even n then div n 2 else n*3+1)) | n <- [2..]] |
| 05:45:02 | <lambdabot> | Couldn't match expected type `a1 -> a -> Bool' |
| 05:45:04 | <lambdabot> | against inferred type `[a2]' |
| 05:45:06 | <lambdabot> | Probable cause: `S.toList' is applied to too many arguments |
| 05:45:08 | <lambdabot> | [0,1,2,8,3,6,9,17,4,20,7,15,10,10,18,18,5,13,21,21,8,8,16,16,11,24,11,112,1... |
| 05:45:15 | <jeffwheeler> | Is it just me, or does the linking stage take up a _lot_ of memory, compared to the rest of the compilation process? |
| 05:45:15 | <dmwit> | :t \f -> filter f . Data.Set.toList |
| 05:45:16 | <lambdabot> | forall a. (a -> Bool) -> S.Set a -> [a] |
| 05:45:36 | <copumpkin> | @pl \f -> filter f . Data.Set.toList |
| 05:45:36 | <lambdabot> | (. Data.Set.toList) . filter |
| 05:45:39 | <jeffwheeler> | I can usually tell when a compilation gets to linking, because my system slows down and my music pauses a few times. |
| 05:45:51 | <jeffwheeler> | (Granted, I'm on a fairly old P4, but still . . .) |
| 05:46:19 | <copumpkin> | jeffwheeler: yeah, it takes a lot of memory |
| 05:46:26 | <copumpkin> | it's not just ghc |
| 05:55:07 | <mhaggag> | Hello, a hopefully quick question: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2470#a2470 |
| 05:55:17 | <mhaggag> | This is from CH05 in "Real World Haskell" |
| 05:55:42 | <mhaggag> | So far I like adding my function types as a form of documentation, and to help myself learn faster as well |
| 05:56:10 | <mhaggag> | If you scroll down to the getobject/getArray functions, I first wrote down their types as returning "Maybe JObject/JArray" |
| 05:56:21 | <copumpkin> | I wonder how that http://hackage.haskell.org/trac/ghc/wiki/AddingNewPrimitiveOperations page worked, as there's definitely something missing from it |
| 05:56:22 | <mhaggag> | Which the compiler complained about, since neither JObject nor JArray is a type constructor |
| 05:56:29 | <copumpkin> | unless something has changed since it was written |
| 05:56:33 | <dmwit> | mhaggag: Yep, this trips up new people all the time. |
| 05:56:38 | <Lemmih> | mhaggag: JObject and JArray aren't types. They're like True and False. |
| 05:56:52 | <mhaggag> | Right, they're value constructors. So my question is: |
| 05:56:57 | <dmwit> | mhaggag: There are two namespaces here: *type* constructors (like JValue) and *value* constructors (like JObject and JArray). |
| 05:57:14 | <dmwit> | Oh, you knew that bit. =) |
| 05:57:35 | <mhaggag> | Is there away to avoid duplicating the parameters of the value constructors when writing down the function type? |
| 05:57:45 | <mhaggag> | Say I later change the way a JObject is stored |
| 05:57:51 | <mhaggag> | I don't want to have to change the function types to follow suit |
| 05:58:06 | <dmwit> | I'm afraid you'll have to. |
| 05:58:10 | <Lemmih> | mhaggag: You could use type synonyms. |
| 05:58:11 | <dmwit> | However, you can declare a new name for a type. |
| 05:58:26 | <dmwit> | Then use that name everywhere; then you only have to change it one place. |
| 05:58:28 | <dmwit> | So: |
| 05:58:36 | <dmwit> | type JObjectType = [(String, Value)] |
| 05:58:51 | <Lemmih> | type JArray = [JValue]; data JValue = ... | JArray JArray |
| 05:59:05 | <dmwit> | then data JValue = ... | JObject JObjectType | ... and getObject :: JValue -> Maybe JObjectType |
| 05:59:38 | <dmwit> | (Of course you can just call it "JObjectType", too, I just named it that way to help disambiguate the two.) |
| 05:59:51 | <copumpkin> | ACTION really looks forward to having a GHC on the iphone |
| 05:59:52 | <dmwit> | err... can just call "JObjectType" as "JObject", I mean |
| 06:00:50 | <mhaggag> | Hold on...you're saying I can define it as: "type JObject = [(String, Value)]" and that wouldn't clash with the value constructor JObject, because it's a value constructor, not a type constructor. right? |
| 06:01:41 | <dmwit> | Right! |
| 06:01:50 | <Berengal> | Right. Type names and constructors live in two different namespaces |
| 06:01:53 | <copumpkin> | dolio: compile is done :) |
| 06:02:01 | <dolio> | Nice. |
| 06:02:03 | <mhaggag> | Awesomesauce. I just tried, and it does work. Thanks a lot! :) |
| 06:02:22 | <copumpkin> | dolio: know of a way to run ghci from the source tree without making a bindist? |
| 06:02:37 | <dolio> | Not really sure. |
| 06:05:25 | <Lemmih> | copumpkin: './srcpath/ghc --interactive' doesn't work? |
| 06:05:46 | <copumpkin> | Lemmih: I don't know where the final ghc gets put |
| 06:05:51 | <copumpkin> | but I'll see if I can find it |
| 06:09:45 | <copumpkin> | I can do inplace/ghc-stage2 --interactive |
| 06:09:51 | <copumpkin> | is that equivalent? |
| 06:10:01 | <Lemmih> | Yes, I think so. |
| 06:12:20 | <ManateeLazyCat> | dmwit: I use `Data.Set.findMin` and `Data.Set.filter` solve my problem, and function "mInd n xs | n < 0 = Nothing | otherwise = listToMaybe . drop n $ xs" is safer function, thanks! |
| 06:12:38 | <copumpkin> | :o |
| 06:14:20 | <dancor_> | i was using hdbc-postgresql, but i want to be able to get the value of an auto-incrementing column as i do an insert. what should i do? |
| 06:22:37 | <copumpkin> | I wish GHC already had a nice way to do natural-parametrized types (without the ugly type-level integer things) |
| 06:22:53 | <copumpkin> | I could then make a really nice interface to the gmp arbitrary precision floats |
| 06:26:36 | <copumpkin> | dolio: bah, the build system doesn't like me :/ |
| 06:27:18 | <copumpkin> | I built the whole thing and it worked, but I forgot to add my new function to the export list of GHC.Integer, so I added it |
| 06:27:32 | <copumpkin> | and now I get epic linker errors from a whole bunch of unrelated things |
| 06:28:10 | <copumpkin> | ACTION sighs and runs make clean... again |
| 06:33:08 | <dancor_> | oh i can just make use of postgres's currval('my_seq') looks like |
| 06:40:50 | <Gilly> | dancor_: "INSERT ... RETURNING id" worked for me but I'm using Takusen |
| 06:41:33 | <chadnickbok> | Hi |
| 06:42:02 | <dancor_> | Gilly: ah thanks. maybe i'll try Takusen |
| 06:44:53 | <Gilly> | dancor_: I used doQuery when doing the insert so I could get the return value. Seemed to work. |
| 06:51:49 | <copumpkin> | aha, the final word on the Z-encoding: http://darcs.haskell.org/ghc/compiler/utils/Encoding.hs |
| 06:59:41 | <Neut> | Can I get some help with the recursion in the courPoints function? |
| 06:59:43 | <Neut> | http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2471#a2471 |
| 07:00:20 | <Neut> | Cause its a guard it stops once it finds one which is valid |
| 07:00:29 | <copumpkin> | dolio: works great |
| 07:00:56 | <dolio> | Awesome. |
| 07:01:04 | <copumpkin> | Prelude GHC.Integer> modExpInteger (3^17) (4^20000) (7^160) |
| 07:01:04 | <copumpkin> | 618928464574875079049335204395986400456569777502324620865987838839989511452489437121589504952607045885791727658022613342936830757656286 |
| 07:01:28 | <dolio> | Is that right? |
| 07:01:42 | <copumpkin> | it was correct on the smaller integers I tried it on :P |
| 07:01:46 | <dolio> | :) |
| 07:01:50 | <copumpkin> | proof by induction ;) |
| 07:02:44 | <Gracenotes> | hm. that'd be interesting, in practice. Proving a function on a, b, c, where a = b = c = 0, and then proving that given any a b c, it's true for (a+1) b c, a (b+1) c, and a b (c+1) |
| 07:03:10 | <copumpkin> | not sure that holds |
| 07:03:18 | <Gracenotes> | I'm not sure either |
| 07:03:25 | <Neut> | Can I get some help with the recursion in the courPoints function? |
| 07:03:26 | <Neut> | http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2471#a2471 |
| 07:03:52 | <dmwit> | Why wouldn't that hold? |
| 07:04:03 | <erikc> | what's the best package for doing runtime loading/linking of code? is it still hs-plugins? |
| 07:04:06 | <Gracenotes> | seems like it should. Perhaps it needs to be proven, though >_> |
| 07:04:13 | <dmwit> | It might be hard to prove those particular induction steps for most functions, but they seem valid enough to me. |
| 07:04:31 | <dmwit> | erikc: The GHC API, I guess. |
| 07:04:40 | <dmwit> | erikc: There's stuff like hint, too, now. |
| 07:04:59 | <dmwit> | Neut: I'm not sure I understand what's wrong with your code. What problem are you having? |
| 07:05:24 | <Neut> | dmwit: because I have used guards it doesn't recurse threw, ie once it finds Jacks it only counts the jacks |
| 07:05:32 | <Neut> | It doesn't keep going and check for Queens etc |
| 07:05:59 | <dmwit> | I wouldn't think you would want recursion for that, anyway. |
| 07:06:13 | <Neut> | How would you do it? |
| 07:06:37 | <outchanter> | is it supposed to be "countRank hand Jack" on the right hand side for every case? |
| 07:07:00 | <Neut> | No I realised that once I pasted, but it doesn;t make a difference |
| 07:07:07 | <Neut> | it should be the card its checking for |
| 07:07:12 | <Neut> | to times by that number |
| 07:07:22 | <copumpkin> | dolio: so what do you think is needed... mpz_invert, mpz_fac, mpz_root, mpz_rootrem, mpz_sqrt, mpz_sqrtrem, mpz_perfect_power_p, mpz_perfect_square_p, (maybe jacobi, legendre, and kronecker?) (the prime functions in IO/ST) ? |
| 07:07:30 | <copumpkin> | I guess not ST |
| 07:07:31 | <dmwit> | sum [countRank hand rank * score | (rank, score) <- [(Jack, 1), (Queen, 2), {- and so on -}]] -- seems reasonable |
| 07:07:49 | <dolio> | copumpkin: I'd just put in as many as you can, if it's easy. |
| 07:07:57 | <copumpkin> | fair enough |
| 07:08:03 | <dmwit> | Or some variation on that. In any case, some maps and folds or a nice list comprehension seem like the way to go here. |
| 07:08:22 | <dmwit> | But even better would be to simply have a function "score :: Rank -> Int". |
| 07:08:44 | <dmwit> | Then it would be "courPoints = sum . map score". Simple. =) |
| 07:08:50 | <dmwit> | +t |
| 07:09:05 | <dolio> | copumpkin: I'm not sure if both sqrt and sqrtrem are worth doing, of course. You could just do the latter and project out the former in Haskell. |
| 07:09:15 | <dmwit> | Well, sum . map (score . fst), I guess. But you get the idea. |
| 07:09:42 | <dolio> | I'm not sure if there'd be a serious performance hit for that or not. |
| 07:09:45 | <copumpkin> | dolio: I guess assuming it's not a lot more efficient |
| 07:09:50 | <copumpkin> | yeah |
| 07:10:01 | <copumpkin> | it seems reasonable |
| 07:10:16 | <dolio> | It might matter if you're doing it in a really tight loop, but then, why would you? |
| 07:10:21 | <Neut> | dmwit: list comprehension did the trick |
| 07:10:22 | <copumpkin> | who knows :P |
| 07:10:23 | <Neut> | thanks |
| 07:10:30 | <copumpkin> | a crazy euler problem |
| 07:10:35 | <copumpkin> | ;) |
| 07:10:46 | <copumpkin> | some new form of asymmetric cryptography |
| 07:10:51 | <copumpkin> | can't think of much else that would use this |
| 07:13:04 | <copumpkin> | dolio: I don't know much about the algorithms behind this stuff... you think it's even worth separating the sqrt from the general root? |
| 07:13:17 | <dolio> | No idea. |
| 07:13:31 | <copumpkin> | I guess if they provided them separately, I'll provide them separately |
| 07:13:33 | <copumpkin> | doesn't cost me much |
| 07:14:25 | <sm_> | is there an existing lib that "openBrowserOn -- Attempt to open a web browser on the given url, all platforms." would fit into ? |
| 07:14:55 | <sm> | System.IO ? |
| 07:15:33 | <sm> | System.Process ? |
| 07:16:37 | <sm> | System.WebBrowser ? |
| 07:17:01 | <sm> | ACTION guess the last |
| 07:29:11 | <jeffz`> | sm, System.DesktopIntegration maybe? |
| 07:40:08 | <erikc> | ugh, using hint inflates the executable size...a little bit |
| 07:45:44 | <twb> | Does cabal run GHC with -Wall by default? |
| 07:46:07 | <ivanm> | twb: I don't think so... |
| 07:46:29 | <twb> | ivanm: I tried ./Setup build --ghc-option=-Wall, but it didn't seem to do anything differently. |
| 07:48:29 | <ivanm> | is Fast Packed Strings a precursor to Bytestrings? |
| 07:49:11 | <Cale> | ivanm: yes |
| 07:49:29 | <ivanm> | thought so |
| 07:52:04 | <ivanm> | is ndm's page on tagsoup here still valid? http://community.haskell.org/~ndm/darcs/tagsoup/tagsoup.htm |
| 07:52:08 | <ivanm> | ? |
| 07:52:34 | <chu_> | hey guys, I'm looking for a way to deal with random numbers, specifically, I have an arbitrary list, and want to grab a random element from it, I can't find anything myself, does anyone have any references I could look at? |
| 07:53:40 | <twb> | chu_: find the length of the list, then than the nth element from the list, where n is a random number between zero and the list length. |
| 07:53:57 | <twb> | chu_: so your new question is: how do you generate a random number. |
| 07:54:05 | <chu_> | Well, I have that much |
| 07:54:06 | <chu_> | :) |
| 07:54:24 | <twb> | hoogle(1) turns up some hits for "random". |
| 08:01:06 | <kuribas> | Does anyone know if this library is production quality? http://www.carlssonia.org/ogi/Adaptive/ |
| 08:04:43 | <ivanm> | kuribas: define "production quality" |
| 08:04:46 | <Cale> | It looks extremely old... |
| 08:05:29 | <ivanm> | there's a 0.22 on hackage |
| 08:05:36 | <kuribas> | ivanm: Fast enough to create an interactive application. |
| 08:05:38 | <ivanm> | and adaptive-containers by dons version 0.3 |
| 08:05:53 | <ivanm> | kuribas: oh, I thought you were implying _stability_ |
| 08:06:36 | <ivanm> | which is the normal definition of "production quality" that I've heard |
| 08:06:45 | <kuribas> | I see. |
| 08:07:16 | <kuribas> | I am more concerned with memory usage and speed. |
| 08:07:45 | <kuribas> | It's the only library I found that does incremental computing. |
| 08:08:21 | <kuribas> | I want to write an interactive music notation program, where any changes to the score are automatically propagated. |
| 08:08:22 | <Cale> | Well, I can imagine the implementation of priority queues as lists might be a little bit slow |
| 08:08:52 | <Cale> | But it really depends on how big the computations get. |
| 08:08:56 | <kuribas> | I could replace it then. |
| 08:09:48 | <Cale> | Right, if it does what you want, then take it. If it's slow, you can always profile things and figure out what needs replacing. |
| 08:10:11 | <kuribas> | Right. |
| 08:10:20 | <Gracenotes> | , reallyUnsafePointerEquality 4 4 |
| 08:10:22 | <lunabot> | luna: Not in scope: `reallyUnsafePointerEquality' |
| 08:10:35 | <Gracenotes> | , reallyUnsafePtrEquality 4 4 |
| 08:10:39 | <lunabot> | False |
| 08:11:06 | <Gracenotes> | hm. Does anyone know how this is defined? |
| 08:11:10 | <Berengal> | , let a = 4 in reallyUnsafePtrEquality a a |
| 08:11:12 | <lunabot> | True |
| 08:11:44 | <Gracenotes> | it might be from reallyUnsafePtrEquality# (GHC.Prim), but it seems more advanced |
| 08:12:03 | <Berengal> | More advanced how? |
| 08:13:22 | <chu_> | I have tried to write a random function, but it fails (it's only 2 lines so that could explain why), could I paste it here and have someone help? I'm guessing it has to do with my non-existent understanding of monads... |
| 08:13:49 | <Berengal> | @paste |
| 08:13:49 | <lambdabot> | Haskell pastebin: http://hpaste.org/new |
| 08:13:57 | <Cale> | chu_: We can have a look |
| 08:14:13 | <chu_> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5180#a5180 |
| 08:14:22 | <Gracenotes> | Berengal: well, for one, it returns True/False instead of an Int# |
| 08:14:33 | <copumpkin> | the Int# just gets translated to Bool |
| 08:14:38 | <copumpkin> | I think they're identical |
| 08:15:21 | <Cale> | chu_: Seems to work in that it picks a random index from 0 up to the length of the list. |
| 08:15:26 | <voker57__> | chu_: swap getStdRandom and randomR calls |
| 08:15:34 | <Cale> | what? |
| 08:15:38 | <voker57__> | eh... |
| 08:15:39 | <Gracenotes> | I don't think so |
| 08:15:49 | <Berengal> | chu_: Works on my machine |
| 08:15:55 | <Gracenotes> | I# (reallyUnsafePtrEquality# 4 4) -> yields 1 |
| 08:16:04 | <Gracenotes> | let a = 4 in I# (reallyUnsafePtrEquality# a a) -> yields 1 |
| 08:16:12 | <Gracenotes> | not the same results as above |
| 08:16:26 | <voker57__> | no, i'm wrong |
| 08:16:33 | <Berengal> | Gracenotes: Did you notice the part where it says "reallyUnsafe"? |
| 08:16:45 | <Berengal> | I'm betting RT is not something you can depend on |
| 08:16:53 | <Gracenotes> | I'd at least like to see the source |
| 08:17:07 | <Gracenotes> | if it's as simple as I#'ing it and checking against 0/1 |
| 08:18:03 | <chu_> | It apparantly cannot deduce (Random a) from the context of (Num a) a possible fix is to append (Random a) to the type signature for randomList, however I have no definition of randomList |
| 08:18:20 | <Cale> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5180#a5181 |
| 08:18:39 | <Cale> | chu_: uhh... |
| 08:18:48 | <Cale> | chu_: That looks like an error not associated with this code |
| 08:19:23 | <chu_> | Well, if I comment out the drawInt function it runs :) |
| 08:20:03 | <Cale> | What's the exact error message you're getting? |
| 08:20:23 | <chu_> | No |
| 08:20:27 | <chu_> | Works, now :) |
| 08:20:28 | <chu_> | Cheers |
| 08:20:29 | <Berengal> | chu_: If you have a type signature for the function that fails, try killing it and let ghc infer it for you |
| 08:20:31 | <chu_> | Your version |
| 08:20:31 | <Cale> | okay :) |
| 08:20:40 | <chu_> | Thanks heaps |
| 08:20:49 | <Cale> | Probably something else isn't a list of Ints |
| 08:21:07 | <Cale> | Or doesn't expect an IO Int, but an IO <something else> ? |
| 08:21:28 | <Cale> | anyway, seems okay now :) |
| 08:21:49 | <Berengal> | Cale: Num a => a's are usually unified with Int with no trouble though |
| 08:22:07 | <Cale> | Not if they need to be polymorphic... |
| 08:22:12 | <Cale> | But I don't know. |
| 08:22:23 | <Berengal> | If that were the case, the error message would be different |
| 08:22:43 | <Cale> | chu_: You should also be aware that putting your whole algorithm in IO for the sake of random numbers is a bit drastic if that's what you're doing. |
| 08:23:14 | <Cale> | chu_: but if it's something that already has to be in IO, this isn't too bad |
| 08:26:11 | <dons> | Cale: you should write the definition guide to random numbers in haskell |
| 08:26:11 | <lambdabot> | dons: You have 3 new messages. '/msg lambdabot @messages' to read them. |
| 08:26:15 | <dons> | srsly FAQ :) |
| 08:27:23 | <Cale> | dons: I did that a long time ago, sort of, it was on the old wiki, but since the original questioner wasn't around to give an attribution, it was lost. |
| 08:28:24 | <Berengal> | I can't find a de-facto standard Random monad anywhere. Is there one? |
| 08:29:26 | <Cale> | There's a MonadRandom package on hackage |
| 08:30:08 | <Berengal> | Ah, yes. |
| 08:31:55 | <sayyestolife> | hmm, I'm trying to do a function that replace a certain char with another, but I can't seem to get the lambda right.. This is what I have so far "replace search replacement subject = map (\x if x == search then replacement) subject" |
| 08:32:16 | <sayyestolife> | and it doesn't compile |
| 08:32:33 | <Berengal> | sayyestolife: Your if needs an else clause |
| 08:32:43 | <sayyestolife> | oh that is true |
| 08:33:04 | <sayyestolife> | it still doesn't compile though |
| 08:33:17 | <Berengal> | You also need the -> arrow in the lambda |
| 08:33:40 | <sayyestolife> | Hmm.. Where? |
| 08:33:45 | <outchanter> | after \x |
| 08:33:53 | <Berengal> | What he said |
| 08:34:03 | <sayyestolife> | ah okay |
| 08:34:46 | <Gilly> | When using a relation db is it usually better to transfer only the ids of rows in the program and do small queries whenever you need some data or do one big query and transfer it all between functions? The problem with the first one is that pure functions will need their data in one shot anyways. |
| 08:40:23 | <tetha> | mm, from my limited experience with databases, I recall that databases dislike tiny queries and the connection to the database tends to dislike gigantic queries, at least if its a network |
| 08:41:42 | <Gilly> | well, it's local and the data includes only some text / integer fields, lot of them but not much in bytes. |
| 08:42:23 | <Gilly> | the db i'm using is postgresql |
| 08:43:16 | <tetha> | if its not large, just get everything you need and look if its too slow |
| 08:43:51 | <Gilly> | yea, i guess that's the way :P |
| 08:44:48 | <Berengal> | Let the db do as much work as possible. That way you get the best of both world: small dataset fetched in a single query. |
| 08:44:48 | <tetha> | I mean, it will be slow due to something different by one of the laws of software optimization |
| 08:45:24 | <Berengal> | Else, use lazy queries |
| 08:46:30 | <voker57__> | @hoogle a -> [a] -> [a] -> [a] |
| 08:46:30 | <lambdabot> | Language.Haskell.TH.Syntax mkNameG_tc :: String -> String -> String -> Name |
| 08:46:30 | <lambdabot> | Prelude enumFromThenTo :: Enum a => a -> a -> a -> [a] |
| 08:46:30 | <lambdabot> | Language.Haskell.TH CondE :: Exp -> Exp -> Exp -> Exp |
| 08:46:47 | <Gilly> | Well, specialized queries would be the best but I think it makes the separation of GUI and DB a bit harder since different GUIs could need different queries. |
| 08:46:52 | <voker57__> | @hoogle (a -> Bool) -> [a] -> [a] -> [a] |
| 08:46:53 | <lambdabot> | Distribution.Simple.Utils equating :: Eq a => (b -> a) -> b -> b -> Bool |
| 08:46:53 | <lambdabot> | Data.Ord comparing :: Ord a => (b -> a) -> b -> b -> Ordering |
| 08:46:53 | <lambdabot> | Distribution.Simple.Utils comparing :: Ord a => (b -> a) -> b -> b -> Ordering |
| 08:46:57 | <chu_> | Can I "create" a local variable in a do expression? Like x <- p * q or something..... |
| 08:47:11 | <copumpkin> | let x = p * q |
| 08:47:12 | <Berengal> | chu_: You can use let |
| 08:47:18 | <chu_> | Awesome |
| 08:47:25 | <shachaf> | chu_: Though it isn't a "variable", just a binding. |
| 08:47:59 | <voker57__> | @hoogle a -> [a] -> ([a], [a]) |
| 08:48:00 | <lambdabot> | Prelude splitAt :: Int -> [a] -> ([a], [a]) |
| 08:48:00 | <lambdabot> | Data.List splitAt :: Int -> [a] -> ([a], [a]) |
| 08:48:00 | <lambdabot> | Data.List genericSplitAt :: Integral i => i -> [b] -> ([b], [b]) |
| 08:48:54 | <chu_> | parse error on input let? |
| 08:49:46 | <chu_> | i see |
| 08:50:43 | <shachaf> | > runIdentity $ do { let x = 5; return x } |
| 08:50:44 | <lambdabot> | <no location info>: parse error on input `}' |
| 08:50:48 | <chu_> | maybe not |
| 08:51:13 | <shachaf> | > runIdentity $ do { let { x = 5 }; return x } |
| 08:51:14 | <lambdabot> | 5 |
| 08:52:45 | <chu_> | thanks shachaf |
| 08:53:44 | <chu_> | Should I really worry about working out all values before printing, or just print as I know the value? If that makes sense... |
| 08:55:38 | <shachaf> | chu_: More context might make more sense. :-) |
| 08:56:04 | <Berengal> | chu_: Not very. In the context of lazy evaluation, 'print' is likely to be (one of) the first functions your program calls. The rest of the program is mostly spent figuring out what exactly it is printing |
| 08:57:34 | <chu_> | I have a few variables and I print them all out at the end, I could print out p (which requires a list comprehension and then the random grab from that list), before working out q (neither have any implications on the other), but normally I would work everything out then print the two values at the end. Just really wondering what's considered better practice in Haskell I guess |
| 08:59:10 | <Berengal> | do {let x = foo; print x; let y = bar; print y} and do {let x = foo; let y = bar; print x; print y} will have very similar executions, if not identical |
| 08:59:41 | <chu_> | yep, either way I'll get the same answer (I think), but is there a "prefered" form? |
| 09:01:26 | <chu_> | Basically, I'm writing an implementation of RSA as I was taught (which is from a maths course), I just wanted to write Euler's gcd algorithm in haskell, but it was easier than I thought (I love recursion :)), so decided on writing the complete thing :p |
| 09:02:19 | <chu_> | I have the bare bones, though no checking that the input values were in fact prime numbers... |
| 09:02:27 | <Gracenotes> | not just the gcd algorithm, but the extended version... |
| 09:02:35 | <Gracenotes> | if that's what you mean |
| 09:02:43 | <chu_> | Yeah, haven't actually got to that point yet, but that will be fun too. |
| 09:02:46 | <Gracenotes> | :) |
| 09:03:29 | <Gracenotes> | plus some modular exponentiation (like, Russian peasant) |
| 09:03:53 | <Gracenotes> | lots of number theory reached with just the RSA algorithm :D |
| 09:03:55 | <chu_> | Yep :) |
| 09:04:34 | <chu_> | It's a fun maths course (foundations of mathematics, we covered modular arithmetic and that's where RSA popped up) |
| 09:05:05 | <chu_> | The follow-on course is called Cryptography and Number Theory ;) |
| 09:06:12 | <b_jonas> | chu_: do you write a probabilistic composite test too, or just use one from a library (like gmp)? |
| 09:06:46 | <chu_> | Well, I guess I will try writing my own, but probably give up :p |
| 09:06:48 | <b_jonas> | just out of curiosity |
| 09:06:54 | <b_jonas> | it's not hard |
| 09:07:02 | <Adamant_> | chu_: just remember, full "real" versions of RSA have a lot of fiddly bits to protect against various attacks. but, implementing a casual version of RSA is fun, and good luck :) |
| 09:07:05 | <b_jonas> | at least if you don't want it too efficent |
| 09:07:17 | <b_jonas> | and I guess you don't |
| 09:07:31 | <b_jonas> | Adamant_: sure, you need a block cipher to code the bulk of text fast |
| 09:07:31 | <chu_> | Yeah, it's only for fun really |
| 09:07:48 | <Adamant_> | chu_: hope you have fun! :) |
| 09:08:14 | <Adamant_> | b_jonas: not even that. RSA is sensitive to a lot of potential attacks from implementation errors. |
| 09:08:27 | <b_jonas> | Adamant_: sure |
| 09:09:02 | <b_jonas> | Adamant_: you need a cryptographically secure random generator which is HARD, |
| 09:09:12 | <b_jonas> | and lots of real world details mathematicians don't even think about |
| 09:09:23 | <Adamant_> | b_jonas: you usually punt and use the OS's |
| 09:09:35 | <b_jonas> | Adamant_: well sure, but someone has to implement that too |
| 09:09:39 | <Adamant_> | right. |
| 09:09:54 | <b_jonas> | chu_: if you have the Cormen book, it describes the Rabin-Miller test quite well |
| 09:09:55 | <Adamant_> | b_jonas: I mean more like, if you don't pad RSA messages correctly |
| 09:10:02 | <Adamant_> | you weaken the encryption |
| 09:10:04 | <chu_> | Cormen book?! |
| 09:10:12 | <Adamant_> | Intro to Algorithms |
| 09:10:30 | <Adamant_> | good lighterweight TAOCP substitute |
| 09:10:59 | <outchanter> | SICP has Rabin-Miller as an exercise IIRC |
| 09:11:26 | <chu_> | Funnily enough, I actually do have the Cormen book :( |
| 09:11:56 | <chu_> | I remember there were some MIT lectures on google video which taught directly from the text |
| 09:14:28 | <cayennext> | I wanted to play with Parsec this weekend. I am on Ubuntu, installed ghc6-parsec-dev. But while compiling a simple program "import Parsec", it cannot find parsec library. I am running out of ideas. Could you help me? |
| 09:14:41 | <copumpkin> | Text.Parsec? |
| 09:14:48 | <copumpkin> | Text.ParserCombinators.Parsec ? |
| 09:15:08 | <cayennext> | tahnk you very much |
| 09:18:21 | <bo0ts__> | Good morning, if I define "addVectors a b = (fst a + fst b, snd a + snd b)" it type is "addVectors :: (Num a, Num b) => (a, b) -> (a, b) -> (a, b)". But isn't this the same as "addVectors :: (Num a) => (a, a) -> (a, a) -> (a, a)"? Is there any difference? |
| 09:18:44 | <bo0ts__> | And more specifically: Why does the type inferer does it this way? |
| 09:20:36 | <outchanter> | the first way would work on any pair of numeric types |
| 09:21:05 | <Berengal> | bo0ts__: The numbers in the pairs don't have to be the same type. You could have a vector of (Int, Double) if you wanted |
| 09:21:10 | <monadic_kid> | it's not the same, the compiler has inferred the most general types, as long as what ever subsitutes a and b are instances of the Num type classes you can add them |
| 09:23:08 | <bo0ts__> | But (Num a) => (a, a) -> (a, a) -> (a, a) works on (Int, Double) Tuples as well. |
| 09:23:21 | <Berengal> | No it doesn't |
| 09:23:23 | <bo0ts__> | Or am I wrong? Let me check. |
| 09:23:49 | <copumpkin> | the same type variable appearing in the type signature |
| 09:23:50 | <Berengal> | Since there's only one type variable, only one type can be substituted for it |
| 09:23:52 | <copumpkin> | implies that the types must be the same |
| 09:24:06 | <copumpkin> | Berengal said it better |
| 09:24:07 | <copumpkin> | :( |
| 09:24:18 | <Berengal> | ACTION flexes |
| 09:24:19 | <copumpkin> | ACTION cuts himself some more |
| 09:24:32 | <outchanter> | ACTION hands copumpkin some antiseptic |
| 09:24:34 | <copumpkin> | I should probably go to sleep rather than wasting time on ghc primops that no one wants |
| 09:24:47 | <Berengal> | I thought cohalloween was last month... |
| 09:24:54 | <bo0ts__> | It does: addVectors (3, 3.2) (4, 4) -> (7.0,7.2) |
| 09:25:10 | <Berengal> | bo0ts__: That's because all those literals are doubles |
| 09:25:25 | <monadic_kid> | bo0ts__: (a, a) implies that the types of the tuple are the same, (Int, Double) have different types |
| 09:25:52 | <monadic_kid> | bo0ts__: you can't subtitute (Int, Double) for (a, a) |
| 09:26:04 | <monadic_kid> | bo0ts__: you can subtitute (Int, Double) for (a, b) |
| 09:26:12 | <copumpkin> | :t 1 |
| 09:26:13 | <chu_> | b_jones - what if I had a function which returned a list of all factors of an input value, if the factors are just [1, n] it would be prime, and just composite anything that is not-prime? |
| 09:26:14 | <lambdabot> | forall t. (Num t) => t |
| 09:26:15 | <copumpkin> | :t 1.5 |
| 09:26:16 | <lambdabot> | forall t. (Fractional t) => t |
| 09:26:20 | <copumpkin> | :t 1 :: Double |
| 09:26:22 | <lambdabot> | Double |
| 09:26:24 | <copumpkin> | :t 1.5 :: Int |
| 09:26:26 | <lambdabot> | No instance for (Fractional Int) |
| 09:26:26 | <lambdabot> | arising from the literal `1.5' at <interactive>:1:0-2 |
| 09:26:26 | <lambdabot> | Possible fix: add an instance declaration for (Fractional Int) |
| 09:26:28 | <copumpkin> | :) |
| 09:27:05 | <Berengal> | @type let x = 3; y = x / 1.5 in x |
| 09:27:06 | <lambdabot> | forall t. (Num t) => t |
| 09:27:21 | <Berengal> | Ah, no MR here |
| 09:27:37 | <copumpkin> | you only get MR with f = g . h iirc ? |
| 09:27:49 | <copumpkin> | if you know what I mean |
| 09:27:49 | <zachk> | mr? |
| 09:27:54 | <copumpkin> | monomorphism restriction |
| 09:27:56 | <Berengal> | copumpkin: You get MR with all "foo = ..." declarations |
| 09:28:36 | <copumpkin> | that seems even odder, if it isn't a function |
| 09:28:47 | <copumpkin> | I can just barely see the justification for it if it's a function |
| 09:29:03 | <Berengal> | copumpkin: Neither is f = g . h |
| 09:29:10 | <Berengal> | If you squint a bit at least |
| 09:29:14 | <copumpkin> | yeah, I guess |
| 09:29:27 | <copumpkin> | meh :) |
| 09:30:01 | <Berengal> | The result of functions has to be monomorphic. 3 is the result of 'fromInteger (3::Integer)', 3 has to be monomorphic |
| 09:30:47 | <Berengal> | With -XNoMR it's the opposite: 3 is polymorphic |
| 09:31:03 | <Berengal> | and so is x where x = 3 |
| 09:31:20 | <Gracenotes> | :> |
| 09:31:53 | <Berengal> | Of course, I might be talking nonsense, but at least this is how I keep track of things, and it has proven to be consistent so far... |
| 09:32:00 | <copumpkin> | wow Gracenotes |
| 09:32:21 | <copumpkin> | go to sleep! |
| 09:33:19 | <Gracenotes> | no u |
| 09:34:23 | <Gracenotes> | does anyone else know, off the top of their head, the three mirth-related words beginning with "joc"? |
| 09:34:42 | <wli> | jocular is one |
| 09:34:43 | <Gracenotes> | is it a "thing"? |
| 09:35:05 | <copumpkin> | jocund? |
| 09:35:10 | <Berengal> | jocose? |
| 09:35:11 | <Gracenotes> | yep |
| 09:35:13 | <Gracenotes> | :) |
| 09:35:23 | <Gracenotes> | I wonder if people group them, though |
| 09:35:24 | <copumpkin> | jockstrap |
| 09:35:25 | <Berengal> | W|A to the rescue! |
| 09:35:26 | <copumpkin> | ;) |
| 09:35:28 | <Gracenotes> | I do certainly |
| 09:35:32 | <Berengal> | http://www75.wolframalpha.com/input/?i=joc___ |
| 09:35:32 | <Gracenotes> | Berengal: cheating! |
| 09:35:43 | <Gracenotes> | copumpkin: lol |
| 09:35:57 | <copumpkin> | definitely mirth :) |
| 09:36:07 | <Gracenotes> | o_O |
| 09:36:15 | <Berengal> | Hmm, jocoseness, jocosity |
| 09:36:20 | <Gracenotes> | jocundity |
| 09:36:26 | <copumpkin> | the mac os dictionary works just as well |
| 09:36:28 | <Gracenotes> | real world |
| 09:36:29 | <copumpkin> | as alpha |
| 09:36:30 | <Gracenotes> | *word |
| 09:39:08 | <Gracenotes> | ur jocundity is showin |
| 09:58:05 | <edwardk> | ACTION waves hello. |
| 09:58:14 | <copumpkin> | omg an edwardk |
| 09:58:18 | <copumpkin> | you're up late/early :o |
| 10:01:03 | <edwardk> | late =) |
| 10:01:09 | <copumpkin> | same here |
| 10:01:59 | <edwardk> | been trying to get to sleep for 4-5 hours now, finally gave up and hopped on channel. |
| 10:02:08 | <copumpkin> | aw |
| 10:02:16 | <copumpkin> | pity no one's around |
| 10:02:26 | <copumpkin> | I guess it'll put you to sleep more quickly |
| 10:02:40 | <edwardk> | meh, made some progress on my parsers as a result of my being stuck awake |
| 10:02:47 | <Heffalump> | morning |
| 10:02:55 | <Heffalump> | ACTION just had a nice lie-in |
| 10:02:57 | <copumpkin> | hi :) |
| 10:03:31 | <edwardk> | trying to get a cheap enough monoid for CFGs or PEGs that its a win to use the LZ78 stuff on something stronger than a regular expression |
| 10:05:09 | <edwardk> | but right now the asymptotics on the algorithms i have for anything stronger seems to not pan out in favor of using the monoid, unless i do so with tricks, like resuming from the error productions you commonly see in production LALR grammars and relying on some meta properties about how they are placed |
| 10:06:13 | <wli> | I don't entirely understand GLR but it has some interesting ideas kicking around. |
| 10:06:45 | <wli> | Like the DAG instead of stack. |
| 10:07:09 | <mm_freak> | say i have a thread, which runs some message loop (reading commands from a chan), what is the easiest way to signal this thread to exit? |
| 10:07:47 | <copumpkin> | kill it with fire! |
| 10:07:53 | <copumpkin> | or make a command that'll make it quit? |
| 10:08:04 | <copumpkin> | (that you'd pass it through the chan) |
| 10:08:12 | <tetha> | kill -9 will do so :) |
| 10:09:22 | <copumpkin> | *sigh*, GHC builds take forever |
| 10:09:32 | <copumpkin> | I need a THz computer |
| 10:10:26 | <tetha> | we need the paralization man to make it go faster somehow |
| 10:10:52 | <copumpkin> | if I had a THz computer, I wouldn't care too much about parallelization though |
| 10:11:30 | <tetha> | neither about heating, I'd guess |
| 10:11:35 | <copumpkin> | :) |
| 10:11:59 | <ivanm> | tetha: sure you would |
| 10:12:06 | <ivanm> | you'd worry about having too _much_ heating! |
| 10:13:06 | <p_l> | ivanm: actually, he would worry about not freezing to death. The only cpus that reach 100GHz run in cryogenic conditions :D |
| 10:13:23 | <ivanm> | heh |
| 10:13:46 | <ivanm> | of course, we just need to think of a better type of computer architecture than x86... |
| 10:13:47 | <p_l> | (superconductors) |
| 10:14:11 | <ivanm> | ACTION wonders what a haskell-oriented CPU would be like, just as how most CPUs these days are C-oriented |
| 10:14:13 | <tetha> | don't go into quantum computers... I recently saw two examples of algorithms for them and I still am confused |
| 10:14:35 | <ivanm> | lol |
| 10:14:43 | <ivanm> | you're in good company then :p |
| 10:14:58 | <Botje> | ACTION took a quantum computing course this year |
| 10:14:59 | <p_l> | ivanm: they are not so much C-oriented, I think. x86 is backward-compatibility oriented ;-) |
| 10:15:04 | <Botje> | it's pretty cool :) |
| 10:15:07 | <kuribas> | We need to compile to fpga's. |
| 10:15:15 | <Botje> | ivanm: i suppose you saw the reduceron? |
| 10:15:31 | <ivanm> | p_l: they're aimed at C-style programming (i.e. imperative) |
| 10:15:36 | <ivanm> | Botje: don't think so... |
| 10:15:38 | <ivanm> | ACTION googles |
| 10:15:48 | <ivanm> | wikis, rather |
| 10:15:58 | <ivanm> | OK, I do have to google... |
| 10:16:06 | <copumpkin> | hah |
| 10:16:10 | <copumpkin> | Prelude GHC.Integer> factInteger 5# |
| 10:16:10 | <copumpkin> | Bus error |
| 10:16:19 | <ivanm> | lol |
| 10:16:38 | <copumpkin> | I guess that one needs more work :P |
| 10:17:14 | <Peaker> | ivanm: did you see the Reduceron? |
| 10:17:17 | <Botje> | is factInteger :: Integer# -> Either Bus Integer# ? :) |
| 10:17:25 | <p_l> | ivanm: well, you can try resurrecting one of those stackmachines :P |
| 10:17:38 | <ivanm> | Peaker: why are you and Botje suddenly both interested in asking me the same question? :p |
| 10:17:45 | <copumpkin> | Botje: unfortunately not :) |
| 10:17:53 | <copumpkin> | Prelude GHC.Integer> modExpInteger (5^12) (123^123) (7^77) |
| 10:17:54 | <copumpkin> | 87331940191622035906076347996440999531349066847140312619844183175 |
| 10:17:56 | <p_l> | ACTION prefers RISCs which can be exploited in interesting ways by HLLs :P |
| 10:17:58 | <ivanm> | :o |
| 10:17:59 | <copumpkin> | that one still works, thankfully :) |
| 10:18:28 | <gio123> | does somebody know latex editor supports utf-8? |
| 10:18:45 | <ivanm> | gio123: emacs |
| 10:18:52 | <copumpkin> | I use texshop or textmate |
| 10:19:04 | <Peaker> | ivanm: ah, didn't see |
| 10:19:09 | <ivanm> | Peaker: ;-) |
| 10:19:14 | <Saizan> | ACTION wonders how to write tests for a prettyprinter without a parser |
| 10:19:24 | <ivanm> | the big red highlighting here makes it more obvious, I suppose :p |
| 10:19:27 | <b_jonas> | Saizan: compare with fixed strings |
| 10:19:38 | <Saizan> | b_jonas: i guess |
| 10:19:52 | <b_jonas> | Saizan: like "[4, 2]" == show [4, 2] |
| 10:20:11 | <copumpkin> | well, tomorrow we'll all be able to do our proejct euler problems a little bit faster with GHC head! |
| 10:20:17 | <copumpkin> | but now I must sleep |
| 10:20:26 | <copumpkin> | :P |
| 10:20:28 | <b_jonas> | p_l: in fact it's the other way: C is x86 oriented |
| 10:20:38 | <Peaker> | b_jonas: C predates x86? |
| 10:20:43 | <b_jonas> | Peaker: I know |
| 10:20:53 | <ivanm> | copumpkin: you? sleep? |
| 10:20:55 | <b_jonas> | but they made the ieee floating point standard to mostly match 8087 |
| 10:20:57 | <ivanm> | you're joking, right? :p |
| 10:21:04 | <Peaker> | C is Von Neumann oriented... |
| 10:21:20 | <b_jonas> | and also most cpus have the wrong kind of divison which is why c89 allows it and c99 requires it now |
| 10:21:26 | <copumpkin> | ivanm: I do sleep occasionally! |
| 10:22:07 | <p_l> | b_jonas: C was made as structured assembler for PDP-11, which was very CISCy. So no wonder it meshes well with x86 :D |
| 10:24:32 | <Peaker> | what's wrong about ieee division? |
| 10:24:56 | <b_jonas> | (sorry, technical problem) |
| 10:25:20 | <Peaker> | b_jonas: what's wrong about ieee division? |
| 10:25:34 | <b_jonas> | Peaker: no, not that division |
| 10:25:38 | <b_jonas> | Peaker: I'm talking about integer division |
| 10:25:43 | <p_l> | brb - rebooting Windows Router |
| 10:25:48 | <b_jonas> | Peaker: rounding the quotient towards zero instead of towards minus infinity |
| 10:27:05 | <Peaker> | b_jonas: why is that wrong? |
| 10:27:21 | <Peaker> | > (-1) `div` 2 |
| 10:27:22 | <lambdabot> | -1 |
| 10:27:33 | <Peaker> | > (-1) `quot` 2 |
| 10:27:34 | <lambdabot> | 0 |
| 10:27:44 | <Peaker> | > (-1) `mod` 2 |
| 10:27:45 | <lambdabot> | 1 |
| 10:27:55 | <Peaker> | > (-1) `rem` 2 |
| 10:27:56 | <lambdabot> | -1 |
| 10:28:08 | <Peaker> | b_jonas: ah, indeed divMod is much nicer to use |
| 10:29:12 | <b_jonas> | Peaker: luckily some languages provide both in the library (like r6rs) |
| 10:29:17 | <b_jonas> | or only the right one |
| 10:30:24 | <Peaker> | b_jonas: well, that's not a major thing in C.. C has worse faults |
| 10:30:46 | <b_jonas> | Peaker: sure, but p_l mentioned cpus |
| 10:30:49 | <Peaker> | (its array degradation horror, its pointer syntax, its lack of parametrized types, ...) |
| 10:31:05 | <b_jonas> | Peaker: there's a nice writeup about the history of C somewhere |
| 10:33:08 | <emmy> | heyyy |
| 10:33:26 | <b_jonas> | anyway, going back to read the Lem book now |
| 10:33:38 | <Botje> | good morning, emmy |
| 10:33:39 | <MyCatVerbs> | Peaker: lck of parametrized types is hardly a horror in a language whose *compilers* had to fit within roughly one megabyte! |
| 10:34:22 | <MyCatVerbs> | That said, we're no longer in those days, so yeah. No real reason why we can't do better *now*. |
| 10:34:24 | <p_l> | 1 megabyte? 32kb |
| 10:34:29 | <Peaker> | MyCatVerbs: I didn't say it was a horror, just a fault :) |
| 10:34:48 | <Peaker> | I think there's a low-hanging fruit here -- a C-like language with modern features |
| 10:34:53 | <emmy> | any guy here |
| 10:34:54 | <Peaker> | but nobody's taking it |
| 10:35:09 | <Peaker> | C++ was supposed to handle it, but it did it all wrong :) |
| 10:35:41 | <Botje> | emmy: if you have a question, just ask |
| 10:35:50 | <p_l> | C++ was created with job security as a goal :P |
| 10:36:29 | <RayNbow> | C++ is just an odd name... the name itself is full of evil side effects :p |
| 10:36:38 | <MyCatVerbs> | Peaker: BitC? |
| 10:36:56 | <Peaker> | MyCatVerbs: Lisp syntax :-( |
| 10:37:12 | <MyCatVerbs> | Peaker: so? |
| 10:37:24 | <MyCatVerbs> | Got any *relevant* problems with it? |
| 10:38:25 | <Peaker> | MyCatVerbs: There are many developers who don't want to use a Lisp syntax (and I sympathize). I looked at BitC a while ago, and it does not seem like what I wanted, but I might be wrong |
| 10:38:52 | <Peaker> | I want a strict, Haskell-like language, possibly with manual memory management (Still not sure if GC is really a problem in a systems programming language) |
| 10:39:35 | <wli> | Peaker: I think it is because it's a bootstrapping question: it needs to be used to implement memory management). |
| 10:40:05 | <maltem> | You can use ATS to pretend you were not programming in C |
| 10:40:20 | <Peaker> | wli: Maybe it is possible to implement GC in a GC'd language, as long as you're careful not to cause allocation feedback loops.. |
| 10:41:17 | <wli> | Just because it's possible doesn't make it useful, desirable, un-awkward, etc. |
| 10:41:56 | <wli> | The memory management subsystems of kernels, for instance, do a lot of strange things and get a lot of churn. That kind of interaction sounds nightmarish to someone who deals with that. |
| 10:43:33 | <wli> | There are a lot of placement (esp. alignment) issues, for instance. |
| 10:44:34 | <wli> | They're already pretty nasty just because of the demands going around without tripping over such a bootstrapping problem. |
| 10:44:35 | <yitz> | yay! ghc compiles again on tiger. hope they apply the patch soon on macports. |
| 10:51:43 | <thomastc> | is it evil to use Control.OldException |
| 10:51:43 | <thomastc> | ? |
| 10:51:59 | <thomastc> | I've got some code here that won't compile on ghc 6.10 because of changes in Control.Exception |
| 10:52:26 | <thomastc> | and the insertion of the three characters "Old" is the simplest solution :) |
| 10:52:38 | <mauke> | is it cabalized? |
| 10:52:48 | <thomastc> | yes |
| 10:53:04 | <Saizan> | add base < 4 to the build-depends then |
| 10:54:31 | <yitz> | thomastc: i think it's not much harder than that to support the new exceptions though. |
| 10:55:00 | <yitz> | usually |
| 10:55:56 | <skanev> | hey guys |
| 10:56:06 | <thomastc> | yitz: ok |
| 10:56:07 | <thomastc> | doSafe :: IO a -> (String -> IO a) -> IO a |
| 10:56:08 | <thomastc> | doSafe = catchJust (\ex -> Just $ show ex) |
| 10:56:09 | <skanev> | Can someone tell me what is the difference between import and import qualify |
| 10:56:12 | <thomastc> | this gives me an error |
| 10:56:21 | <skanev> | or at least, point me to the proper documentation. I have hard time finding it :) |
| 10:56:36 | <yitz> | @hoogle doSafe |
| 10:56:36 | <lambdabot> | No results found |
| 10:56:46 | <yitz> | @hoogle catchJust |
| 10:56:46 | <lambdabot> | Control.Exception catchJust :: Exception -> Maybe b -> IO a -> b -> IO a -> IO a |
| 10:56:48 | <yitz> | heh |
| 10:57:06 | <thomastc> | hoogle still has the 6.8 definition? |
| 10:57:22 | <thomastc> | :t catchJust |
| 10:57:23 | <lambdabot> | Not in scope: `catchJust' |
| 10:57:47 | <thomastc> | http://stackoverflow.com/questions/431527/ambiguous-type-variable-error-msg describes the same error I'm getting |
| 10:57:56 | <thomastc> | albeit on a different function, but I doubt that it matters |
| 10:58:30 | <thomastc> | skanev: http://en.wikibooks.org/wiki/Haskell/Modules#Qualified_imports |
| 10:58:41 | <thomastc> | oh :( |
| 11:00:01 | <dancor_> | Gilly: do you know if it's possible to use type-annotations for all functions when using Takusen? it seems like you need certain things that are not exported (like Database.PostgreSQL.Enumerator.QueryStringTuned) to write out your type annotations |
| 11:00:51 | <yitz> | thomastc: weird, there seem to be parens missing in that type |
| 11:03:42 | <thomastc> | yitz: yes indeed... hoogle bug? |
| 11:03:51 | <thomastc> | the web hoogle does it right |
| 11:04:29 | <thomastc> | but either way, this is the old definition of catchJust... is there an easy way to make it work with the new one? |
| 11:05:03 | <igel> | how important is it that 'show' produces valid haskell code? |
| 11:07:01 | <dancor_> | > show const |
| 11:07:02 | <lambdabot> | Overlapping instances for Show (a -> b -> a) |
| 11:07:03 | <lambdabot> | arising from a use ... |
| 11:07:09 | <dancor_> | > show (const :: Int -> Int) |
| 11:07:10 | <lambdabot> | Couldn't match expected type `Int' against inferred type `b -> Int' |
| 11:07:38 | <dancor_> | anyway, i saw a "(String -> String)" the other day, which is def not valid code |
| 11:08:24 | <igel> | well the thing is atm show produces valid haskell code, but it includes functions that are not exported by the module :) |
| 11:08:38 | <dancor_> | but since there isn't really anything else you could do for a Show instance for (String -> String), i guess it's ok |
| 11:08:41 | <dancor_> | ah |
| 11:09:24 | <dancor_> | well show's often have "fromList" (unqualified) for things that are always imported qualified, right? |
| 11:09:43 | <igel> | yep |
| 11:09:46 | <dancor_> | i can offer you justifications but not advice ;) |
| 11:09:54 | <igel> | :) |
| 11:11:20 | <Gilly> | dancor_: had the same problem myself, i'd have needed Database.PostgreSQL.Enumerator.ColumnBuffer and Query. Worked without writing the annotation, though. |
| 11:11:43 | <Gilly> | Maybe they should be exported for this purpose, *shrug*. |
| 11:12:19 | <igel> | i'd rather remove the show instance than export this function |
| 11:12:39 | <yitz> | thomastc: there are parens missing in the latest online docs also. |
| 11:12:50 | <yitz> | http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#5 |
| 11:13:03 | <dancor_> | ya. i guess the current intent is that you just won't do annotations. unfortunately then i can't figure out compiler errors. maybe i'll hack takusen to export those things at least for me for now.. |
| 11:13:34 | <sayyestolife_> | hello |
| 11:13:57 | <dancor_> | @faq Life? |
| 11:13:57 | <lambdabot> | The answer is: Yes! Haskell can do that. |
| 11:14:20 | <thomastc> | yitz: haddock bug, then? |
| 11:14:27 | <Heffalump> | thomastc: yes |
| 11:16:32 | <sayyestolife_> | So, I'm wondering what is a good way to implement a "game loop", at the moment I have a function that calls itself recursively (until game is over), and it doesn't feel very pretty |
| 11:17:02 | <igel> | foo = do myloop; foo |
| 11:17:07 | <igel> | you can also write |
| 11:17:13 | <igel> | foo = forever myloop |
| 11:17:20 | <igel> | that's pretty :) |
| 11:17:40 | <igel> | :t forever |
| 11:17:41 | <dancor_> | sayyestolife_: functional reactive programming is pretty but not really all figured out yet theoretically afaict |
| 11:17:41 | <lambdabot> | forall (m :: * -> *) a. (Monad m) => m a -> m () |
| 11:17:53 | <sayyestolife_> | okay, because I don't want to explode the stack |
| 11:18:06 | <sayyestolife_> | dancor, okay |
| 11:18:12 | <igel> | sayyestolife: the compiler will figure taht out |
| 11:18:16 | <dancor_> | http://hackage.haskell.org/cgi-bin/hackage-scripts/package/reactive |
| 11:18:18 | <igel> | especially if you use "forever" |
| 11:18:21 | <dancor_> | version 0.10.7 :/ |
| 11:18:25 | <sayyestolife_> | igel okay cool |
| 11:20:51 | <yitz> | thomastc: dunno. anyway, I found it in the sources. It's: |
| 11:21:01 | <yitz> | catchJust :: Exception e => (e -> Maybe b) -> IO a -> (b -> IO a) -> IO a |
| 11:22:16 | <yitz> | Control.Exception.Base |
| 11:22:30 | <yitz> | so that's right for you, isn't it? |
| 11:23:38 | <thomastc> | yitz: yes, that's the one I'm trying to use |
| 11:23:53 | <thomastc> | but the function I pasted still uses the old def and gives an error on the new one |
| 11:24:03 | <thomastc> | I'll just depend on base < 4 for now |
| 11:26:14 | <yitz> | thomastc: maybe try doSafe = catchJust (Just . show . toException) |
| 11:26:48 | <yitz> | thomastc: instead of doSafe = catchJust (Just . show) like you have now |
| 11:29:15 | <thomastc> | :t fromException |
| 11:29:16 | <lambdabot> | Not in scope: `fromException' |
| 11:30:04 | <thomastc> | yitz: that gives me the same error, but on fromException instead of catchJust |
| 11:32:30 | <burp_> | jo |
| 11:32:35 | <burp_> | oops |
| 11:51:23 | <sayyestolife_> | is any of the FRP-gui-libraries actually used commercially? |
| 11:53:14 | <Peaker> | sayyestolife_: I think Anygma is using them |
| 11:53:24 | <Peaker> | not sure if its truly gone into use yet |
| 11:59:21 | <dancor_> | why isn't there an (instance (Monad m) => Applicative m) |
| 12:00:16 | <opqdonut> | ?instances WrappedMonad |
| 12:00:17 | <lambdabot> | Couldn't find class `WrappedMonad'. Try @instances-importing |
| 12:00:20 | <opqdonut> | hmh |
| 12:00:27 | <mauke> | dancor_: because then you couldn't have any other instances of Applicative |
| 12:00:37 | <opqdonut> | ?instances-importing Control.Applicative WrappedMonad |
| 12:00:39 | <lambdabot> | Couldn't find class `WrappedMonad'. Try @instances-importing |
| 12:00:54 | <dancor_> | sounds like fixing the wrong problem? |
| 12:00:58 | <opqdonut> | anyway, Monad m => Applicative (WrappedMonad m) |
| 12:01:18 | <Peaker> | what's a Wrapped Monad? |
| 12:01:29 | <opqdonut> | Peaker: it's just a newtype |
| 12:01:40 | <opqdonut> | to make instances easier |
| 12:01:45 | <Peaker> | dancor_: Haskell lacks this kind of relationship, it would create overlapping instances |
| 12:01:47 | <opqdonut> | anyway, there is something wrong with the current typeclass system |
| 12:02:05 | <opqdonut> | we need either chooseable instances or something completely different |
| 12:02:17 | <opqdonut> | for these deep hierarchies we're seeing |
| 12:02:28 | <Peaker> | I think overlapping instances should be proven/assumed equivalent |
| 12:02:43 | <Peaker> | there's also the class aliases idea |
| 12:02:47 | <opqdonut> | overlappinginstances is almost nice |
| 12:03:04 | <opqdonut> | but you can't have both "instance Foo a => Bar a" and "instance Quux a => Bar a" |
| 12:03:07 | <McManiaC> | @pl map (\_ -> ' ') |
| 12:03:07 | <lambdabot> | map (const ' ') |
| 12:04:12 | <EvilTerran> | opqdonut, what if there were a type that was an instance of both Foo and Quux? |
| 12:04:30 | <opqdonut> | that is the question |
| 12:05:44 | <Peaker> | opqdonut: you mean its logistically too difficult to get such remote instances to have identical semantics? |
| 12:06:09 | <Peaker> | opqdonut: if they do have identical semantics, just choose one arbitrarily |
| 12:06:17 | <dancor_> | i have imported a monad from a library and the monad has no applicative instance, and i want it to have the monadic one. should i write the instance (in terms of the monad operators), or do something crazy with WrappedMonad (i can't determine what tho) |
| 12:06:22 | <opqdonut> | Peaker: thus undecideableinstances |
| 12:06:27 | <opqdonut> | but this is a slippery slope |
| 12:06:53 | <opqdonut> | we need something more fundamental, something backed with solid type theory |
| 12:07:00 | <dancor_> | sometimes things are applicatives in two ways. i think it should be possible to do even that.. |
| 12:07:08 | <opqdonut> | yes, that's a related problem |
| 12:07:11 | <opqdonut> | chooseable instances |
| 12:07:33 | <opqdonut> | for example taking the contexts of instance decls into account while deducing might give enough power |
| 12:07:46 | <opqdonut> | but IIRC there were some undecideability concerns there |
| 12:08:14 | <dancor_> | it seems like you definitely have to specify which one to use |
| 12:08:27 | <opqdonut> | indeed, but that can get cumbersome also |
| 12:08:27 | <Peaker> | I think if there are two ways for (Maybe a) to be a Monoid, then it should really be two different types |
| 12:08:30 | <dancor_> | a <*.2 b :) |
| 12:08:35 | <Peaker> | the way Maybe is a Monoid is part of the type Maybe |
| 12:08:59 | <opqdonut> | Peaker: but you it would be nice for standard library functions to have just a Maybe version |
| 12:09:06 | <opqdonut> | and not an OtherMaybe one also |
| 12:09:08 | <opqdonut> | :t find |
| 12:09:10 | <lambdabot> | forall a. (a -> Bool) -> [a] -> Maybe a |
| 12:09:12 | <Peaker> | And if you want to force explicit instance choosing -- then have instances ONLY on newtypes, and not on data's |
| 12:09:25 | <dancor_> | should there be a maybeable class |
| 12:09:30 | <opqdonut> | dancor_: maybe |
| 12:09:33 | <dancor_> | lol |
| 12:09:43 | <Peaker> | opqdonut: you could have Maybe a, and RecursiveMonoidMaybe and LeftChoiceMonoidMaybe |
| 12:09:55 | <opqdonut> | but the semantics of chaining maybes needs to be separated from the semantics of Maybe itself (this is a value or maybe not) |
| 12:09:57 | <Peaker> | opqdonut: with shorter names, of course :) |
| 12:10:14 | <opqdonut> | Peaker: yeah, that might work with some syntax sugar for dissecting the newtypes |
| 12:10:34 | <Peaker> | opqdonut: if you disallow instances on data, and force people to use newtype to declare instances, you've effectively created an instance selection mechanism |
| 12:11:11 | <opqdonut> | Peaker: of course instance selection is feasible technology-wise |
| 12:11:19 | <opqdonut> | but it needs to be nice to use also |
| 12:11:46 | <twb> | @pl \x -> x == 1 || x == 2 |
| 12:11:47 | <lambdabot> | liftM2 (||) (1 ==) (2 ==) |
| 12:11:48 | <Peaker> | I think explicit instance naming will lead to non-global instances which are imported specifically/etc, and I think that's extra complexity that is not warrented |
| 12:11:54 | <twb> | Ew. |
| 12:12:05 | <Peaker> | twb: why? That's pretty |
| 12:12:15 | <twb> | Not pretty enough |
| 12:12:21 | <Peaker> | twb: you have an OR between the results of (1==) and (2==) |
| 12:12:45 | <mauke> | :t (`elem` [1, 2]) |
| 12:12:46 | <lambdabot> | forall a. (Num a) => a -> Bool |
| 12:12:50 | <Peaker> | liftA2 (||) (1==) (2==) |
| 12:13:03 | <Peaker> | or that :) |
| 12:13:49 | <opqdonut> | (||) <$> (1==) <*> (2==) |
| 12:14:02 | <twb> | The actual code I was looking at is |
| 12:14:06 | <twb> | @pl filter ("temp" `isPrefixOf`) dirfiles ++ filter ("tmp" `isPrefixOf`) dirfiles |
| 12:14:06 | <lambdabot> | filter ("temp" `isPrefixOf`) dirfiles ++ filter ("tmp" `isPrefixOf`) dirfiles |
| 12:14:26 | <Vq^> | flip elem [1,2] |
| 12:14:28 | <opqdonut> | there's probably a neat version with <^ or something |
| 12:14:53 | <opqdonut> | (1==) <^(||)^> (2==) or whatever the names of those operators were |
| 12:15:58 | <Japsu> | d ^____^ b |
| 12:16:08 | <opqdonut> | thanks for the input |
| 12:16:11 | <Japsu> | no wait, you can't use _ in operators |
| 12:16:20 | <Japsu> | d ^.^ b |
| 12:16:58 | <dancor_> | ACTION considers a joint operator-obfuscation/ascii-art contest |
| 12:18:14 | <Vq^> | the freedom to define operators in Haskell removes a lot of the fun in obfuscation |
| 12:18:25 | <Peaker> | the "stack traces for ghc" paper by SPJ is ready for use in 6.10.3? |
| 12:19:19 | <MyCatVerbs> | Vq^: it does rather expand the field, though. |
| 12:19:31 | <Peaker> | @pl \dirfiles -> filter ("temp" `isPrefixOf`) dirfiles ++ filter ("tmp" `isPrefixOf`) dirfiles |
| 12:19:31 | <lambdabot> | ap ((++) . filter ("temp" `isPrefixOf`)) (filter ("tmp" `isPrefixOf`)) |
| 12:21:01 | <Peaker> | @pl \isPrefixOf -> isPrefixOf "temp" <^(||)^> isPrefixOf "tmp" |
| 12:21:01 | <lambdabot> | ap ((^>) . (<^ (||)) . ($ "temp")) ($ "tmp") |
| 12:21:05 | <Peaker> | heh |
| 12:22:07 | <opqdonut> | .. |
| 12:22:30 | <cognominal> | I am refactoring some code and it does not compile anymore : http://paste.factorcode.org/paste?id=696 The error is parse error (possibly incorrect indentation) |
| 12:22:34 | <cognominal> | any clue? |
| 12:23:12 | <opqdonut> | cognominal: check spaces vs tabs |
| 12:23:49 | <mauke> | cognominal: I randomly blame the first 'let' |
| 12:23:52 | <Peaker> | cognominal: I think the let blah = blah $ \n ... requires the stuff in the new line to be at least after the =, but I'm not sure |
| 12:24:09 | <opqdonut> | wow, that let + case + where is horrible |
| 12:24:16 | <Peaker> | or the "where" is not indented properly |
| 12:24:19 | <mauke> | not after the = |
| 12:24:30 | <mauke> | it has to be indented further than the start of the block |
| 12:24:44 | <Peaker> | can "where" be on non-functions? |
| 12:24:51 | <opqdonut> | yeah |
| 12:24:54 | <opqdonut> | i'm wondering too |
| 12:24:54 | <Peaker> | does each let get its own where? |
| 12:25:37 | <cognominal> | what do you suggest? |
| 12:25:56 | <opqdonut> | cognominal: defining all those helper functions with let too |
| 12:26:01 | <mauke> | indent the let block more (by at least 3 spaces) |
| 12:26:04 | <cognominal> | opqdonut, yi does not insert tabs |
| 12:26:08 | <opqdonut> | or even on the top level |
| 12:26:27 | <opqdonut> | as they don't need to be under that closure |
| 12:27:28 | <Teja> | good morning #haskell |
| 12:28:04 | <Wraithan> | Howdy, figured I would setup vim to be more haskell friendly since I have been hacking in haskell a lot lately and was wondering if anyone had a recommended set, haskell vim comes up with tons of pages of plugins and I am just looking for some pointers to one or two of the better sets of plugins |
| 12:28:27 | <opqdonut> | use emacs ;) |
| 12:28:32 | <Wraithan> | s/haskell vim/googling haskell vim/ |
| 12:28:46 | <Wraithan> | opqdonut: bleh, not going to learn another operating system |
| 12:30:54 | <twb> | bracket is basically UNWIND-PROTECT, right? |
| 12:31:01 | <mauke> | yes |
| 12:31:20 | <Wild_Cat> | speaking of editors and all that jazz, is there a web page for the GSoC project about better Haskell Eclipse integration? |
| 12:31:38 | <cognominal> | still struggling with my function :( |
| 12:32:20 | <McManiaC> | @pl \x -> (f x) * (g x) |
| 12:32:21 | <lambdabot> | liftM2 (*) f g |
| 12:32:37 | <Beelsebob> | :( f <^(*)^> g |
| 12:33:43 | <twb> | I thought Eclipse was an IDE, not an editor. |
| 12:34:00 | <Beelsebob> | it is |
| 12:34:49 | <McManiaC> | show . length . show $ 5 |
| 12:34:56 | <McManiaC> | is there a "prettier" way? |
| 12:35:11 | <opqdonut> | in terms of syntax, no |
| 12:35:15 | <McManiaC> | k |
| 12:35:17 | <Wild_Cat> | twb: it is an IDE (which includes an editor, if you wanna get technical). Hence the "and all that jazz" ;) |
| 12:35:26 | <Beelsebob> | McManiaC: log base 10? |
| 12:35:28 | <opqdonut> | if you want to know how many digits there are, use something else |
| 12:35:30 | <opqdonut> | e.g. log |
| 12:37:46 | <McManiaC> | hmmm how? |
| 12:37:57 | <Beelsebob> | @hoogle log |
| 12:37:58 | <lambdabot> | Prelude log :: Floating a => a -> a |
| 12:37:58 | <lambdabot> | Prelude logBase :: Floating a => a -> a -> a |
| 12:37:58 | <lambdabot> | package logfloat |
| 12:38:03 | <opqdonut> | > floor . logBase 10 . fromIntegral $ 3506 |
| 12:38:05 | <lambdabot> | 3 |
| 12:38:10 | <opqdonut> | > floor . logBase 10 . fromIntegral $ 1000 |
| 12:38:12 | <lambdabot> | 2 |
| 12:38:19 | <opqdonut> | gah, ceiling, not floor |
| 12:38:41 | <Beelsebob> | > logBase 10 . fromIntegral 1000 |
| 12:38:43 | <lambdabot> | No instance for (Num (a -> t)) |
| 12:38:43 | <lambdabot> | arising from a use of `fromIntegr... |
| 12:38:47 | <Beelsebob> | > logBase 10 . fromIntegral $ 1000 |
| 12:38:49 | <lambdabot> | 2.9999999999999996 |
| 12:38:52 | <Beelsebob> | floating point error |
| 12:38:55 | <Beelsebob> | not wrong function |
| 12:38:59 | <opqdonut> | ah |
| 12:39:06 | <opqdonut> | yeah, floats are pretty ugly for that stuff |
| 12:39:15 | <opqdonut> | repeated `div` by 10 might be better |
| 12:39:25 | <Beelsebob> | probably |
| 12:39:35 | <Beelsebob> | but probably as expensive as the show . length . show |
| 12:39:44 | <McManiaC> | ehm |
| 12:40:17 | <opqdonut> | but a bit nicer |
| 12:40:32 | <Beelsebob> | not sure |
| 12:40:37 | <Beelsebob> | show . length . show is pretty nice |
| 12:40:40 | <McManiaC> | what would be the advantage against show . length . show? |
| 12:42:59 | <opqdonut> | well the show of Integer probably just repeatedly divides by 10 and takes the remainder |
| 12:43:34 | <Beelsebob> | opqdonut: believable, but it's a large chunk of code saved |
| 12:43:56 | <opqdonut> | true |
| 12:49:33 | <EvilTerran> | > logBase 10 . fromIntegral $ 1000 :: CReal |
| 12:49:34 | <lambdabot> | 3.0 |
| 12:50:41 | <Peaker> | @src logBase |
| 12:50:42 | <lambdabot> | Source not found. BOB says: You seem to have forgotten your passwd, enter another! |
| 12:51:08 | <EvilTerran> | ?type logBase |
| 12:51:09 | <lambdabot> | forall a. (Floating a) => a -> a -> a |
| 12:51:09 | <skanev_> | @thomastc: Thanks |
| 12:51:10 | <lambdabot> | Unknown command, try @list |
| 12:51:27 | <EvilTerran> | it's a method of Floating, iirc |
| 12:51:47 | <thomastc> | :t toException |
| 12:51:48 | <lambdabot> | Not in scope: `toException' |
| 12:51:51 | <ivanm> | @src Floating |
| 12:51:52 | <lambdabot> | class (Fractional a) => Floating a where |
| 12:51:52 | <lambdabot> | pi :: a |
| 12:51:52 | <lambdabot> | exp, log, sqrt, sin, cos, tan :: a -> a |
| 12:51:52 | <lambdabot> | asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh :: a -> a |
| 12:51:52 | <lambdabot> | (**), logBase :: a -> a -> a |
| 12:52:04 | <Peaker> | @src Double logBase |
| 12:52:04 | <lambdabot> | Source not found. My pet ferret can type better than you! |
| 12:52:08 | <ivanm> | yup, though I'd guess it has a default implementation |
| 12:52:16 | <ivanm> | @src Float logBase |
| 12:52:17 | <lambdabot> | Source not found. Wrong! You cheating scum! |
| 12:52:30 | <EvilTerran> | logBase b x = log x / log b -- ? |
| 12:52:47 | <ivanm> | that's my guess |
| 12:53:04 | <Peaker> | perhaps it loses more accuracy than alternate approaches |
| 12:53:23 | <EvilTerran> | (and, by default, log x = logBase (exp 1) x, perhaps) |
| 12:53:34 | <b_jonas> | how'd it lose accuracy? it has a division only, it's accurate |
| 12:53:38 | <EvilTerran> | > logBase 10 100 -- if i've got the parameters of logBase the right way round |
| 12:53:39 | <lambdabot> | 2.0 |
| 12:53:45 | <b_jonas> | only problem can be if it overflows or underflows |
| 12:55:00 | <Peaker> | b_jonas: well, if it generates a larger number, then the mantissa may have less LSB's? Also, generating two inaccurate doubles and dividing them -- is possibly less accurate than somehow bypassing the division? I'm semi guessing :) |
| 12:55:25 | <b_jonas> | Peaker: it's two accurate doubles unless one of them overflows or underflows |
| 12:55:43 | <Peaker> | b_jonas: if the log is an irrational number then surely they're inaccurate? |
| 12:56:32 | <b_jonas> | yeah, but they're the best approximation for the log provided the input is accurate |
| 12:56:37 | <b_jonas> | log is implemented precisely |
| 12:56:54 | <b_jonas> | (on modern enough machines) |
| 12:56:59 | <b_jonas> | it's just taken from libc |
| 12:57:08 | <Peaker> | b_jonas: well, dividing two best approximations may result in a less accurate result than a best approximation, perhaps? |
| 12:57:25 | <Peaker> | (because the inaccuracies might accumulate? Just my intuition speaking here, though) |
| 12:58:26 | <Peaker> | > log 1000 / log 10 |
| 12:58:28 | <lambdabot> | 2.9999999999999996 |
| 12:58:31 | <b_jonas> | Peaker: it's _division_, not addittion. division or multiplication does not lose accuracy |
| 12:58:33 | <Peaker> | > logBase 10 1000 |
| 12:58:34 | <lambdabot> | 2.9999999999999996 |
| 12:58:48 | <b_jonas> | I'm not saying that logBase is necessarily best implemented that way |
| 12:58:58 | <Peaker> | b_jonas: how come? Isn't the mantissa fixed/finite length? |
| 12:59:03 | <b_jonas> | only that if it is implemented like that, then it is accurate unless there's an overflow or underflow |
| 13:00:17 | <Peaker> | b_jones: so dividing a fully populated mantissa with another fully populated mantissa gives an accurate/correct fully populated mantissa? |
| 13:00:41 | <b_jonas> | Peaker: yes, almost |
| 13:00:49 | <b_jonas> | there is a bit of loss of course but very little |
| 13:01:06 | <Peaker> | b_jonas: well, the fact log 1000 / log 10 is not 3 proves that logBase could be implemented more accurately than that? |
| 13:01:41 | <Peaker> | well, very little inaccuracy is all you need to leak abstractions and break computations, sometimes.. e.g: Raise this inaccurate result to a big power |
| 13:01:46 | <b_jonas> | oh and, by the way, |
| 13:01:58 | <b_jonas> | there can't be an overflow or underflow there because log doesn't go that high |
| 13:02:03 | <wli> | ACTION would probably use Newton and/or binary search after an approximation derived from that. |
| 13:02:24 | <Alpounet> | :) |
| 13:02:47 | <wli> | Or maybe some strategy derived from that that gets upper and lower bounds, polished via binary search -bounded Newton. |
| 13:03:29 | <Peaker> | b_jonas: well, as long as we agree that log division to implement logBase is slightly less accurate than alternate approaches |
| 13:04:32 | <b_jonas> | Peaker: what? what alternate approaches is it less accurate from? |
| 13:05:49 | <Peaker> | b_jonas: something less efficient that results in 3 when you use logBase 10 1000 ? |
| 13:06:02 | <b_jonas> | I mean, you haven't suggested a real alternate approach yet |
| 13:06:53 | <Peaker> | I could implement an integer-based log that worked on that example.. |
| 13:07:13 | <Peaker> | or you could use wli's approach |
| 13:09:29 | <MyCatVerbs> | Peaker: wli's approach is to use log base division (or any other method that gets you close to a right answer) then iteratively get closer and closer approximations to the solution. That still won't necessarily get you exactly 3, depending on how many iterations you want to run it for, but it'll get you darn close. |
| 13:10:20 | <Peaker> | MyCatVerbs: you can do a binary search on the whole mantissa |
| 13:10:51 | <Peaker> | the whole range of doubles is at most 2^64 options long -- a binary search on that should take roughly 64 iterations? |
| 13:13:18 | <MyCatVerbs> | Ooh, plan. Double's mantissa is 53 bits and Float's is 23. |
| 13:14:50 | <Peaker> | you do need to search for the best exponent too |
| 13:16:00 | <MyCatVerbs> | Not so much. Remember that you have fast approximations available to you. |
| 13:18:55 | <McManiaC> | @pl foo x >> bar x |
| 13:18:55 | <lambdabot> | foo x >> bar x |
| 13:18:57 | <McManiaC> | ^^ |
| 13:19:36 | <mmorrow> | @unpl liftM2 (>>) foo bar |
| 13:19:36 | <Peaker> | MyCatVerbs: since the exponent size is pretty small, binary searching that too shouldn't add too much work |
| 13:19:37 | <lambdabot> | (foo >>= \ b -> bar >>= \ a -> return (b >> a)) |
| 13:19:44 | <mmorrow> | arr |
| 13:19:47 | <Peaker> | @pl \x -> foo x >> bar x |
| 13:19:48 | <lambdabot> | liftM2 (>>) foo bar |
| 13:19:59 | <McManiaC> | ah :) |
| 13:20:05 | <mmorrow> | @yarr |
| 13:20:06 | <lambdabot> | Arrr! |
| 13:20:10 | <McManiaC> | :D |
| 13:20:27 | <MyCatVerbs> | Peaker: you're going to get within one bit of the right answer from even a crap approximation anyway! |
| 13:20:57 | <MyCatVerbs> | Peaker: or do you know of logBase approximations that aren't accurate to within 2x in either direction? |
| 13:22:16 | <Peaker> | MyCatVerbs: hmm.. logBase can't really get the exponent wrong, as the exponent, I suppose, should always be the smallest possible that doesn't lose MSB's |
| 13:22:53 | <Peaker> | MyCatVerbs: in which case you just have to search around a very small range of the existing mantissa (far far closer than 2x, probably) |
| 13:24:34 | <MyCatVerbs> | Hrmn. Linux's math.h manpages don't specify the errors. |
| 13:25:01 | <MyCatVerbs> | Still. There are BSD-licensed math routines in the BSDs that do. IIRC log is quoted as something like 100 ULPs. |
| 13:25:31 | <mmorrow> | i'd look here http://opengroup.org/onlinepubs/007908775/xsh/math.h.html |
| 13:25:50 | <mm_freak> | i notice that the run* functions and their cousins (runState, runReader, evalStateT, etc.) are almost always flipped |
| 13:28:23 | <EvilTerran> | mm_freak, yeah, they're defined that way round because that's what you get when you write "newtype State s a = State { runState :: s -> (a,s) }" or whatever |
| 13:28:34 | <EvilTerran> | mm_freak, iirc, monadLib has them flipped as standard |
| 13:28:49 | <mm_freak> | maybe i should have a look at that |
| 13:28:54 | <McManiaC> | im trying to use something like "mapM putStrLn ["foo","bar"]", but i get "Couldn't match expected type `()' against inferred type `[()]'" |
| 13:29:08 | <mm_freak> | McManiaC: use mapM_ |
| 13:29:23 | <McManiaC> | thx! |
| 13:29:33 | <mm_freak> | mapM returns the results, while mapM_ returns () |
| 13:29:37 | <maltem> | Flipped as compared to ...? |
| 13:29:49 | <mm_freak> | since putStrLn results in () two times, you get the list [(), ()] as result with mapM |
| 13:29:51 | <McManiaC> | ok |
| 13:29:52 | <McManiaC> | :) |
| 13:30:19 | <mm_freak> | maltem: i very often write: flip evalStateT someState $ do … |
| 13:30:40 | <mm_freak> | or i use 'flip evalStateT someState' as a closure |
| 13:30:48 | <maltem> | ah ok |
| 13:31:21 | <Twey> | Is there a conventional difference between mapM_ and mapM'? |
| 13:31:39 | <Twey> | I always thought they both just meant ‘modified’, but... |
| 13:31:53 | <maltem> | _ often means "discard some result" |
| 13:32:05 | <maltem> | ' often means "strict variant" |
| 13:47:12 | <McManiaC> | how can i change only one field of a record? |
| 13:47:32 | <mauke> | r{ field = x } |
| 13:48:28 | <Alpounet> | > { field = 1 } |
| 13:48:29 | <lambdabot> | <no location info>: parse error on input `{' |
| 13:48:38 | <Peaker> | I like writing Data.Accessors for a record |
| 13:48:47 | <Peaker> | so I use the same name for a getter and a setter |
| 13:50:27 | <Heffalump> | Peaker: yeah |
| 13:50:33 | <Heffalump> | ACTION should do that more consistently |
| 13:50:44 | <Peaker> | Data.Accessor should be a Control.Category.Category though |
| 13:51:00 | <Peaker> | instead of ^> and ^< it should use >>> and <<< |
| 13:51:03 | <Heffalump> | really? Does anyone actually care about that? |
| 13:51:09 | <Heffalump> | ah, for the nice names? :-) |
| 13:51:23 | <Peaker> | and the nice properties that come with them |
| 13:51:23 | <Heffalump> | yes, that'd be nice. Especially now that F# has similar looking composition operators. |
| 13:52:02 | <Peaker> | also, there's probably some rich library of stuff on categories just waiting to happen and it could benefit from that, theoretically :) |
| 13:52:20 | <Heffalump> | hmm. |
| 13:52:33 | <Heffalump> | categories are so abstract I'm not convinced there's a rich library of stuff possible for them |
| 13:52:34 | <Peaker> | Category also gives you id so you get a "self" accessor |
| 13:52:55 | <Heffalump> | tricky though, overloading id is pretty weird |
| 13:53:02 | <Heffalump> | leads to bad type errors when you get confused |
| 13:53:35 | <Peaker> | so many things remind me I need to find time to work on a type-safety-preserving Haskell code editor :( |
| 13:53:50 | <Heffalump> | you mean a refactoring tool? |
| 13:54:10 | <Peaker> | I want to create a Haskell editor that edits the ASG directly, not a text representation of it - and also preserves type safety for all editing operations |
| 13:54:27 | <Heffalump> | ah |
| 13:54:30 | <Peaker> | Edits are allowed to change functionality, so its not a refactoring per-se |
| 13:54:31 | <Heffalump> | that sounds hard |
| 13:54:40 | <Heffalump> | how would part-written programs work? |
| 13:55:06 | <Heffalump> | writing a usable structure editor in itself is hard |
| 13:55:09 | <Peaker> | When you want an intermediate step that breaks types -- you get a missingConversion :: a -> b = error "Forgot to replace this" installed there by the editor to keep the types safe |
| 13:55:36 | <Peaker> | all the missing conversions you have can be red and appear on an auto-TODO list on the side, like a compiler error list you can avoid repairing until you feel like it :) |
| 13:55:58 | <Peaker> | maybe "type safe" is the wrong word, just "type check" it is :) |
| 13:56:01 | <EvilTerran> | could require edits to be a refinement under the definedness ordering, and start with "undefined :: some type", then refining it stepwise down to an implementation |
| 13:56:21 | <pejo> | Peaker, have you used the emacs Agda mode? |
| 13:56:24 | <Peaker> | EvilTerran: what happens when you change the type of a called function? |
| 13:56:27 | <Peaker> | pejo: nope |
| 13:56:28 | <Heffalump> | that sounds inconvenient if you want to undo... |
| 13:56:34 | <Peaker> | Heffalump: how come? |
| 13:56:45 | <Heffalump> | Peaker: IM EvilTerran's suggestion |
| 13:57:06 | <Heffalump> | undo would become invalid if you can only make your code more defined |
| 13:57:14 | <Heffalump> | and once your code is fully defined, you could never change it |
| 13:57:43 | <RLa> | is there standard function to check is string is substring of some other string? |
| 13:57:56 | <RLa> | i can't find such function in Data.String |
| 13:59:00 | <RLa> | how comes that such primitive function is not in standard library |
| 13:59:15 | <Saizan> | see Data.List |
| 13:59:17 | <mauke> | isInfixOf |
| 13:59:41 | <RLa> | oh, found it |
| 13:59:43 | <RLa> | thanks |
| 13:59:57 | <EvilTerran> | Heffalump, i haven't thought it through, it was just a random idea |
| 14:00:13 | <Peaker> | Heffalump: anyway, if the types consistently check, and the type-inference is "on the fly", then when types break and you get those auto-coercions, its pretty clear what the error means -- because inference won't go haywire and indicate an error someplace else |
| 14:00:26 | <Heffalump> | not sure I see the point of the coercions then |
| 14:00:39 | <Heffalump> | who decides where to put them? |
| 14:00:42 | <Peaker> | Heffalump: the coercions allow you to the intermediate editing that breaks types shortly |
| 14:00:51 | <Peaker> | Heffalump: the editor, whereever needs be to keep the types checking |
| 14:00:53 | <EvilTerran> | Heffalump, and you would be able to replace something fully-defined with something else equally defined (think equational reasoning, Bird style) |
| 14:02:10 | <Peaker> | Heffalump: for example, if you take a function Int -> Int, and change it to String -> Int -> Int, then everyone calling it breaks -- so instead of "Breaking", they get an autoadapter :: (String -> Int -> Int) -> Int -> Int installed on the call (and bookmarked for fixing) so the code keeps type-checking. Then when you get there, the error is much clearer than one you'd get if you'd compile it that way as text.. (This is the type it worked well with, an |
| 14:02:10 | <Peaker> | d this is how it is now) |
| 14:03:09 | <Heffalump> | interesting |
| 14:03:21 | <Heffalump> | one problem is that there are things you can't fix up with a coercion |
| 14:03:38 | <Heffalump> | missing type class instance is one example, but things can get subtler than that |
| 14:03:41 | <Peaker> | Heffalump: the coercion is a->b -- it lets you coerce anything, of course its a runtime error |
| 14:04:23 | <Peaker> | Heffalump: ah, I see what you mean |
| 14:04:53 | <Peaker> | Heffalump: But if I change (Blah a => a) to just b then, it can be coerced back for compatibility? |
| 14:05:07 | <Heffalump> | I don't follow |
| 14:06:06 | <Saizan> | > show undefined |
| 14:06:07 | <lambdabot> | "* Exception: Prelude.undefined |
| 14:06:25 | <Peaker> | Heffalump: you mean if I had a call to mappend on a String, and someone removed the String Monoid instance? |
| 14:06:32 | <Saizan> | that's an ambiguous typeclass constraint without extended defaulting |
| 14:06:58 | <Peaker> | @type undefined |
| 14:06:59 | <lambdabot> | forall a. a |
| 14:07:17 | <Heffalump> | Peaker: yes, for example |
| 14:08:03 | <Peaker> | Heffalump: ah, I guess that can be considered a function deletion.. in which case you can probably convert the call to mappend_deleted of the right type instead of a coercion |
| 14:08:38 | <SamB> | ACTION wonders if he could configure his computer to boot straight into X and lock it with Xscreensaver, securely ... |
| 14:08:41 | <Saizan> | what's the advantage over just annotating the source with the errors like eclipse does? |
| 14:08:55 | <SamB> | Saizan: of what ? |
| 14:08:58 | <Peaker> | Saizan: the types always check -- so the editor can help with completions/etc |
| 14:09:03 | <SamB> | ACTION likes the way slime does that ... |
| 14:09:08 | <Peaker> | Saizan: the type inference can occur in the editor itself, too |
| 14:09:31 | <Saizan> | the second part looks orthogonal to me |
| 14:09:37 | <SamB> | Peaker: are you talking about some crazy structured editor ? |
| 14:09:41 | <SamB> | or what ? |
| 14:09:59 | <Saizan> | the first too, depending on how you do inference |
| 14:10:03 | <Peaker> | Saizan: if the editor has no idea what the types of things are, because they don't even type-check, then it can do less inferencing, less completions, and less execution of the code as you edit it, I believe |
| 14:10:36 | <Peaker> | Saizan: or if it has "partial knowledge" because types don't check - it might infer the wrong types everywhere (the usual thing that happens when you have a type error without top-level signatures) |
| 14:10:42 | <SamB> | Peaker: type inference for completions sounds really hard ... |
| 14:10:50 | <Saizan> | inserting coercions doesn't add knowledge about the types |
| 14:11:03 | <Peaker> | SamB: completions based on actual types that were inferred with type-inference in the editor, as you edit |
| 14:11:15 | <Peaker> | Saizan: it keeps existing knowledge in-tact, instead of re-inferring everything incorrectly |
| 14:11:16 | <walter_> | Would you please give a irc paste URL ? Thanks |
| 14:11:38 | <Peaker> | Saizan: also, it makes the error messages about broken things much more straightforward - because it utilizes knowledge about the change that occurred, rather than just looking at the new broken whole |
| 14:11:40 | <SamB> | Peaker: what types would it be aware of when you were trying to enter the function ? |
| 14:11:42 | <mauke> | http://hpaste.org/fastcgi/hpaste.fcgi/new |
| 14:11:43 | <Saizan> | @paste |
| 14:11:43 | <lambdabot> | Haskell pastebin: http://hpaste.org/new |
| 14:11:49 | <SamB> | the return type, maybe ... |
| 14:11:55 | <walter_> | mauke, thank you |
| 14:12:04 | <SamB> | not usually the argument types yet |
| 14:12:45 | <SamB> | so how do you filter a set of functions on a "could eventually return" relation ? |
| 14:12:51 | <mmorrow> | @type ($ ()) |
| 14:12:53 | <Peaker> | SamB: I am creating a new function? it starts out as: "newFunc = fillThisField" and lets you replace fillThisField (which equals error "missing implementation"), and has type forall a. a |
| 14:12:53 | <lambdabot> | forall b. (() -> b) -> b |
| 14:12:59 | <Peaker> | SamB: when you add an argument it becomes a -> b |
| 14:13:10 | <Peaker> | SamB: when you start using that argument it starts restricting the type based on unifications |
| 14:13:16 | <Peaker> | SamB: and so on |
| 14:13:40 | <SamB> | so you enter the args before going back to the function? |
| 14:14:03 | <Peaker> | SamB: some UI gesture would "add an arg" to the function |
| 14:14:04 | <SamB> | how do you make that easy? |
| 14:14:06 | <SamB> | ACTION gtg |
| 14:14:20 | <Peaker> | SamB: either a keyboard key, or jumping to the function name and pressing "space" or some such |
| 14:15:35 | <mmorrow> | Peaker: that'd be interesting if you came up with some super minimal example/proof-of-concept |
| 14:15:57 | <mmorrow> | (dunno what such a thing would look like or whatever..) |
| 14:16:02 | <walter_> | a little code, I can runghc to get correct result, but can not compile it with ghc. would you please give me some advice ? thanks |
| 14:16:04 | <walter_> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5182#a5182 |
| 14:16:15 | <Peaker> | mmorrow: I am dying to work on this editor, but full-time job is consuming almost all of my mental energies... Last spurt of working on it, I got pretty far in creating a GUI toolkit for it (I think Gtk, Qt, etc are hopeless for creating a good code editor) |
| 14:16:22 | <Heffalump> | walter_: use ghc --make |
| 14:16:36 | <Heffalump> | or ghc -package tagsoup, but --make will figure that out for you |
| 14:17:36 | <walter_> | Heffalump, great, I compiled it successfully. Thank you! |
| 14:17:48 | <mmorrow> | Peaker: i mean though not a functioning program, but just some sort of mock-up or completely-fabricated screen-video of a hypothetical interaction |
| 14:18:14 | <mmorrow> | because personally i have a hard time picturing how what you're talking about would work |
| 14:18:21 | <mmorrow> | and i think that would make it clearer |
| 14:18:23 | <Peaker> | mmorrow: ah, that's pretty difficult to create with any of the tools I know about |
| 14:18:38 | <mmorrow> | Peaker: gimp? ;) |
| 14:18:54 | <Peaker> | heh, imagery might be good enough, might be a good idea :) |
| 14:19:04 | <mmorrow> | exactly! completely imaginary |
| 14:19:11 | <mmorrow> | err, you said imagery.. |
| 14:19:13 | <mmorrow> | that too! |
| 14:19:18 | <Peaker> | heh |
| 14:20:03 | <Saizan> | or just the underlying type-inferrer that should support this |
| 14:20:06 | <Peaker> | visually, I think it would be quite similar to Emacs/vim, at least as a first version -- serializing the ASG to an AST and then rendering it to screen with indentation. The main noticeable difference would be much more useful key bindings that operate on the ASG rather than on the text letters |
| 14:20:48 | <Peaker> | a key binding could show/hide type annotations and stuff like that -- which an image might not capture entirely |
| 14:20:58 | <Peaker> | maybe a presentation could |
| 14:51:21 | <EvilTerran> | ACTION fights with LyX |
| 14:52:10 | <byorgey> | ACTION lends EvilTerran a +4 Wand of Typesetting |
| 14:52:15 | <_JFT_> | dumb question but what is LyX? |
| 14:52:25 | <EvilTerran> | I have a \textrm comment in a math box; i want to include a \vee in that comment. LyX appears to be refusing to let my typeset that regardless of what hoops i jump through. |
| 14:52:28 | <mauke> | let me google that for you |
| 14:52:34 | <_JFT_> | and how do you do the "emote" thing :P |
| 14:52:44 | <_JFT_> | Doh! |
| 14:52:49 | <joga> | /me <does something> :) |
| 14:52:49 | <byorgey> | _JFT_: /me |
| 14:52:50 | <_JFT_> | A TeX? |
| 14:52:58 | <mauke> | also, it's called an "action" |
| 14:53:05 | <_JFT_> | byorgey: Thank you! |
| 14:53:24 | <_JFT_> | ACTION not fully awaken yet |
| 14:53:26 | <povman> | @slap povman |
| 14:53:26 | <lambdabot> | ACTION pushes povman from his chair |
| 14:53:30 | <byorgey> | EvilTerran: just putting it in $ $ doesn't work? |
| 14:53:32 | <povman> | ow |
| 14:53:42 | <EvilTerran> | byorgey, LyX seems to be taking the $s literally |
| 14:53:53 | <byorgey> | EvilTerran: the other thing you might try is using \text instead of \textrm |
| 14:53:58 | <byorgey> | you may have to import amsmath or something |
| 14:54:16 | <byorgey> | \text is much better for text inside of math stuff, and lets you arbitrarily nest $ $ and \text |
| 14:54:30 | <EvilTerran> | ACTION really doesn't like tex |
| 14:55:41 | <pejo> | JFT, it's a visual editor for (la)tex. |
| 14:56:06 | <povman> | who here uses HSSDL |
| 14:56:14 | <_JFT_> | pelo: thanks |
| 14:58:05 | <EvilTerran> | ACTION notes that LyX's "insert math" button seems to be using \mbox, not $...$ |
| 14:58:25 | <byorgey> | mbox isn't for math. |
| 14:58:32 | <EvilTerran> | well, don't blame me. |
| 14:58:40 | <byorgey> | it's just... a box. I don't know what the m stands for. |
| 14:58:40 | <EvilTerran> | i click "insert math", it inserts an mbox. |
| 14:58:46 | <byorgey> | bizarre. |
| 14:58:48 | <mauke> | mathbox! |
| 14:58:56 | <EvilTerran> | it doesn't seem to like nesting math in text in math |
| 14:59:11 | <byorgey> | EvilTerran: the moral of the story is: don't use LyX. |
| 14:59:31 | <EvilTerran> | byorgey, yeah, i think i might just go back to plaintext |
| 14:59:51 | <EvilTerran> | i've already wasted about an hour i really didn't have spare mucking around with this |
| 15:00:00 | <byorgey> | yes, that's what I would suggest |
| 15:00:47 | <byorgey> | using LyX or other "WYSIWYG" editors to edit LaTeX is like trying to paint a picture in the dark |
| 15:01:49 | <EvilTerran> | LyX claims to go for WYSIWY(mean) rather than WYSIWYG, but what *I* see is an unintuitive interface and inscruitable error messages. |
| 15:02:28 | <tetha> | I always thought the good thing about latex is: you can just type and some program creates something nice to read, and thus never understood why things like Lyx exist |
| 15:03:52 | <EvilTerran> | tetha, i've never found that i "can just type and some program creates something nice to read" |
| 15:04:10 | <EvilTerran> | it always tends to turn into "just type and some program creates an incomprehensible error message" |
| 15:04:39 | <tetha> | yes, it teaches you to work in very small iterations |
| 15:04:43 | <tetha> | :) |
| 15:04:58 | <b_jonas> | EvilTerran: but you're a programmer, so "just type and some program creates an incomprehensible error message" should be a perfectly usual experience |
| 15:05:41 | <b_jonas> | you know how to handle that and fix your program |
| 15:06:23 | <Wraithan> | Try the MS STL... you haven't seen incomprehensible until you mess up something using that |
| 15:06:28 | <Wraithan> | (C++ that is) |
| 15:07:20 | <EvilTerran> | ACTION feels that TeX really needs to be replaced by something more appropriate to the current state of computing, but is yet to find such a thing |
| 15:07:51 | <mux> | ACTION has wondered about open-source implementations of XSL-FO |
| 15:08:01 | <EvilTerran> | get rid of this multiple passes nonsense, use a nice formal syntax, etcetc |
| 15:08:02 | <Twey> | EvilTerran: That would be Microsoft Word. I disagree. |
| 15:08:03 | <tetha> | well tex is in the curios situation that tex kind of sucks, but all alternatives I have seen so far suck even more |
| 15:08:15 | <EvilTerran> | Twey, i mean a typesetting language, not a word processor. |
| 15:08:31 | <EvilTerran> | so congrats on disagreeing with something i didn't mean. |
| 15:08:32 | <mux> | I only know of commercial implementations of XSL-FO |
| 15:08:33 | <Twey> | Typesetting languages are, alas, not appropriate to the current state of computing |
| 15:08:58 | <EvilTerran> | if you say so |
| 15:09:06 | <Twey> | Look around |
| 15:09:12 | <Twey> | The ‘current state of computing’ is Windows |
| 15:09:14 | <Wraithan> | I've never used one myself... *shrug* |
| 15:09:22 | <Twey> | It involves lots of pointing and clicking |
| 15:09:27 | <Twey> | We're the outsiders :-P |
| 15:09:33 | <mux> | that's simply not true |
| 15:09:37 | <EvilTerran> | Twey, lots of people still use programming languages. |
| 15:09:50 | <Twey> | A minority |
| 15:09:53 | <Wraithan> | not the majority by a long shot though |
| 15:10:04 | <Twey> | And of that minority, most of them probably use VB |
| 15:10:04 | <maltem> | Twey, TeX sucks from a language (processing) point of view |
| 15:10:24 | <mux> | when we're speaking typesetting language, we're clearly not talking about the lambda computer user to begin with |
| 15:10:25 | <Twey> | maltem: I don't disagree |
| 15:10:54 | <Twey> | Indeed |
| 15:11:28 | <b_jonas> | lambda computer? |
| 15:11:48 | <mux> | pun intended |
| 15:12:49 | <b_jonas> | is that like a pointer machine based architecture with the machine code being structured, instead of one of the current ones that work with numbers and the machine code based on sequentially ran instructions encoded to numbers? |
| 15:13:04 | <walter_> | Can Haskell deal with Big5 or GB2312? |
| 15:13:17 | <mux> | b_jonas: in that context, lambda computer user == usual computer usuer |
| 15:13:33 | <sbahra> | muxxxxxxxxx |
| 15:13:40 | <mux> | oh hey sbahra |
| 15:13:43 | <sbahra> | :] |
| 15:13:53 | <b_jonas> | @faq Can Haskell deal with Big5 or GB2312? |
| 15:13:53 | <lambdabot> | The answer is: Yes! Haskell can do that. |
| 15:14:23 | <b_jonas> | walter_: deal in what way? what operations would you want to do on such data? |
| 15:14:24 | <walter_> | great, where can find the document |
| 15:14:33 | <mux> | walter_: I don't know if there are native implementations for those encodings, but you could still use the bindings to libiconv |
| 15:15:01 | <mux> | those are chinese encodings right? |
| 15:15:06 | <walter_> | yeah |
| 15:15:33 | <walter_> | just download some page and write to a database |
| 15:15:48 | <b_jonas> | just treat them as opaque byte strings then |
| 15:16:00 | <mux> | ACTION nods |
| 15:16:04 | <walter_> | I think libiconv is a good idea |
| 15:16:05 | <b_jonas> | or reencode them |
| 15:16:20 | <mux> | you don't even need libiconv if you don't need to "understand" those encodings |
| 15:16:28 | <b_jonas> | I'd recommend that encoding module because it seems nicely done, |
| 15:16:28 | <mux> | as b_jonas said |
| 15:16:37 | <walter_> | well, something I got is like \123\123\233\ |
| 15:16:50 | <mux> | walter_: but you're using String's, right? |
| 15:16:52 | <b_jonas> | only I've no idea what the new versino has because I couldn't build the haddock documentation |
| 15:17:01 | <walter_> | mux, yeah |
| 15:17:03 | <mux> | walter_: try with ByteString |
| 15:17:15 | <mux> | it'll be faster anyhow |
| 15:17:15 | <b_jonas> | mux: isn't that sort of irrelevatn? |
| 15:17:27 | <b_jonas> | sure but |
| 15:17:39 | <walter_> | good, will try |
| 15:17:41 | <mux> | b_jonas: I don't think so; String's have a builtin encoding |
| 15:17:58 | <mux> | which causes the printing of those escape sequences if I'm not mistaken |
| 15:18:11 | <mux> | whereas the ByteString module treats strings just as sequence of bytes |
| 15:18:19 | <b_jonas> | mux: Strings is how you use them |
| 15:18:28 | <b_jonas> | you can use them as a list of utf characters |
| 15:18:32 | <b_jonas> | decoding bytes to it |
| 15:18:35 | <mux> | but I guess he prints them on a handle at some point :-) |
| 15:18:36 | <b_jonas> | but that's not the only way |
| 15:18:47 | <Wraithan> | Any recommended scripts for vim for haskell ? |
| 15:18:55 | <mux> | so using ByteString's would be much more convenient |
| 15:18:59 | <maltem> | The input/output functions on Strings truncate badly (except in some new version of the libraries, I think) |
| 15:19:00 | <b_jonas> | in fact the ghc Prelude does not use them that way |
| 15:19:08 | <mux> | maltem: http://projects.haskell.org/haskellmode-vim/ |
| 15:19:20 | <b_jonas> | a String can mean anything, just like a number can mean anything |
| 15:19:24 | <mux> | woops |
| 15:19:27 | <mux> | Wraithan: http://projects.haskell.org/haskellmode-vim/ |
| 15:19:41 | <mux> | b_jonas: but they have some intrinsic meaning when you print them |
| 15:19:55 | <mux> | (going in circles here) |
| 15:20:08 | <b_jonas> | mux: it can be a sequence of bytes |
| 15:20:25 | <b_jonas> | mux: if you're reading and writing the same encoding, and not processing much, there's no need to know its meaning |
| 15:20:34 | <b_jonas> | you better just read it as a sequence of bytes |
| 15:20:34 | <mux> | b_jonas: tell me how you hPutStr a String as a sequence of bytes then |
| 15:20:40 | <b_jonas> | (whether in a String or bytestring) |
| 15:20:49 | <mux> | it just doesn't work that way as far as I know |
| 15:20:51 | <maltem> | b_jonas, Char /= Byte |
| 15:21:04 | <mux> | yes, Char is a UTF-8 Char |
| 15:21:09 | <maltem> | no |
| 15:21:11 | <mauke> | mux: wrong |
| 15:21:12 | <mux> | not to be confused with Char8 that is use in ByteString |
| 15:21:14 | <maltem> | a Unicode code point |
| 15:21:16 | <mux> | sorry |
| 15:21:32 | <mux> | utf-8 is an encoding, unicode is a standard, etc, I'll punish myself for that shortcut |
| 15:21:41 | <Wraithan> | Seems to be a arch package for that, looks like I will give it a go |
| 15:21:56 | <b_jonas> | oh I'm tired of this sorry |
| 15:21:58 | <mux> | in any case, using ByteString for opaque sequence of bytes still is the way to go |
| 15:22:30 | <maltem> | it is. |
| 15:22:58 | <mux> | not sure why b_jonas got so worked up over this :-P |
| 15:23:39 | <MyCatVerbs> | Okay, kids. |
| 15:24:03 | <Badger> | Okay, Cats. |
| 15:24:11 | <MyCatVerbs> | mux: hPutStrLn in System.IO currently treats Chars as if they were bytes. That is how b_jonas can treat them as such. |
| 15:24:40 | <MyCatVerbs> | That might change in future, but isn't likely to because it's likely to break existing apps that use it as if it did. |
| 15:25:10 | <mux> | wow, that's broken |
| 15:25:37 | <maltem> | http://www.haskell.org/pipermail/glasgow-haskell-users/2009-February/016558.html |
| 15:25:46 | <maltem> | (about encoding-aware handles) |
| 15:26:26 | <MyCatVerbs> | mux: perhaps. If you want things to work differently, use a library like System.IO.UTF8. |
| 15:26:46 | <MyCatVerbs> | Or wait for one of the Simons to make Handles encoding-aware. |
| 15:27:16 | <mux> | I don't, this wasn't my concern, but walter_'s |
| 15:27:29 | <walter_> | :) |
| 15:29:12 | <walter_> | infact I think I can write a function to convert that all to utf-8, then system.io.utf8 can deal with it. |
| 15:29:37 | <mux> | walter_: you might also be interested in the compactstring package |
| 15:30:00 | <MyCatVerbs> | walter_: System.IO.UTF8 is for using UTF8 with Strings specifically. You'd most likely get better performance using ByteString IO. |
| 15:30:39 | <MyCatVerbs> | walter_: 'specially since, IIRC, all the libiconv bindings use ByteStrings. |
| 15:30:55 | <walter_> | MycatVerbs, yeah, I think so. |
| 15:31:15 | <mux> | walter_: and CompactString are just encoding-aware ByteString |
| 15:31:50 | <walter_> | mux, I see. your advice on ByteString is quite good. Will try |
| 15:32:22 | <walter_> | thanks you all! |
| 15:32:26 | <mmorrow> | , (text . utf8enc) "\x2200" |
| 15:32:28 | <lunabot> | ∀ |
| 15:32:40 | <mmorrow> | , utf8dec "∀" |
| 15:32:42 | <lunabot> | "\NUL" |
| 15:32:45 | <mmorrow> | heh |
| 15:32:50 | <mmorrow> | , utfenc "∀" |
| 15:32:52 | <lunabot> | luna: Not in scope: `utfenc' |
| 15:33:02 | <mmorrow> | , utf8enc "∀" |
| 15:33:04 | <lunabot> | "\226\136\128" |
| 15:33:12 | <mmorrow> | , utf8dec "\226\136\128" |
| 15:33:14 | <lunabot> | "\8704" |
| 15:33:21 | <mmorrow> | , "∀" |
| 15:33:22 | <lunabot> | "\8704" |
| 15:33:44 | <mmorrow> | all you have to do is encode, then you can use regular IO.. |
| 15:34:04 | <mmorrow> | (and decode on the way in) |
| 15:34:07 | <trofi> | , text "hello" |
| 15:34:09 | <lunabot> | hello |
| 15:34:14 | <mmorrow> | , 'text |
| 15:34:16 | <lunabot> | Text.PrettyPrint.HughesPJ.text |
| 15:34:22 | <trofi> | , text "hello\nworld" |
| 15:34:24 | <lunabot> | hello |
| 15:34:24 | <lunabot> | world |
| 15:35:12 | <mmorrow> | , let ntimes n = foldr (.) id . replicate n in ntimes 8 (braces . parens . brackets) (int 42) |
| 15:35:14 | <lunabot> | {([{([{([{([{([{([{([{([42])}])}])}])}])}])}])}])} |
| 15:38:18 | <EvilTerran> | > (fmap (!!) . iterate) f x 10 :: Expr |
| 15:38:19 | <lambdabot> | f (f (f (f (f (f (f (f (f (f x))))))))) |
| 15:39:41 | <EvilTerran> | ACTION would write that as "result (result (!!)) iterate" if "result = (.)" were in scope |
| 15:41:02 | <paper_cc> | is there a pretty name for (flip (.))? |
| 15:41:15 | <mauke> | >>> |
| 15:41:29 | <paper_cc> | @ty (>>>) |
| 15:41:31 | <lambdabot> | forall (a :: * -> * -> *) b c d. (Arrow a) => a b c -> a c d -> a b d |
| 15:41:39 | <EvilTerran> | in the same context as result = (.), i've seen argument = flip (.) |
| 15:41:41 | <mmorrow> | , let ntimes n = foldr (.) id . replicate n in ntimes 6 ((h::Expr->Expr) . (g::Expr->Expr) . f) x :: Expr |
| 15:41:44 | <lunabot> | h (g (f (h (g (f (h (g (f (h (g (f (h (g (f (h (g (f x))))))))))))))))) |
| 15:41:47 | <skorpan> | maybe someone should create a database with things like that, which would be integrated in lambdabot? |
| 15:41:52 | <paper_cc> | mauke: thanks =) |
| 15:42:06 | <EvilTerran> | > let argument = flip (.) in argument (+1) f $ x :: Expr |
| 15:42:07 | <mmorrow> | , fix ((h::Expr->Expr) . (g::Expr->Expr) . f) |
| 15:42:07 | <lambdabot> | f (x + 1) |
| 15:42:09 | <lunabot> | h (g (f (h (g (f (h (g (f (h (g (f (h (g (f (h (g (f (h (g (f (h (g (f (h... |
| 15:42:33 | <paper_cc> | someone should teach Hoogle that b -> c is a special case of (Arrow a) => a b c |
| 15:43:00 | <paper_cc> | (if that's possible, it'd be very nice) |
| 15:43:05 | <Peaker> | what replaces old-locale for System.Locale? |
| 15:43:05 | <EvilTerran> | paper_cc, and of Functor f => f c |
| 15:44:10 | <EvilTerran> | (or indeed Monad m => m c, so Applicative and Functor as well) |
| 15:44:37 | <paper_cc> | ACTION still wonders why there's no (Monad m) => Functor m where fmap = liftM |
| 15:44:52 | <Heffalump> | paper_cc: because it would overlap |
| 15:45:11 | <mmorrow> | , fix (inn . Just) |
| 15:45:14 | <lunabot> | Mu (Just (Mu (Just (Mu (Just (Mu (Just (Mu (Just (Mu (Just (Mu (Just (Mu ... |
| 15:45:20 | <paper_cc> | Heffalump: are there true cases when they don't match? |
| 15:45:25 | <paper_cc> | s/true// |
| 15:45:32 | <sclv> | its also backwards. functor is simpler than monad. |
| 15:45:36 | <Heffalump> | I mean that it would overlap in the sense of overlapping instances. |
| 15:45:52 | <Heffalump> | i.e. it would require GHC extensions that cause their own problems |
| 15:45:57 | <sclv> | if things were set up in a proper hierarchy, liftM would be defined in terms of fmap. |
| 15:45:59 | <jmcarthur> | paper_cc: what you really want is class Functor m => Monad m, not instance Monad m => Functor m |
| 15:46:23 | <jmcarthur> | or, rather, class Applicative m => Monad m |
| 15:46:41 | <Peaker> | sclv: liftM* would not need to exist? |
| 15:46:42 | <paper_cc> | jmcarthur: yes, but it would break a lot of things |
| 15:46:48 | <mux> | does anyone know where I can find the code source of the hackage script that builds documentation? |
| 15:46:56 | <jmcarthur> | paper_cc: so would instance Monad m => Functor m |
| 15:46:59 | <sclv> | Peaker: well, liftM2 requires `ap` as well. |
| 15:46:59 | <mmorrow> | mux |
| 15:47:06 | <sbahra> | mmorrow |
| 15:47:06 | <mmorrow> | mux: probably in the hackage-server |
| 15:47:12 | <Peaker> | sclv: liftM2 = liftA2 anyway |
| 15:47:12 | <mmorrow> | sbahra! |
| 15:47:17 | <sbahra> | :] |
| 15:47:22 | <mmorrow> | ::) |
| 15:47:30 | <mux> | mmorrow: thank you |
| 15:47:34 | <mmorrow> | mux: it's on code.haskell.org/hackage-server iirc |
| 15:47:42 | <mux> | yeah, google helped me to it |
| 15:47:55 | <mmorrow> | google is pretty handay |
| 15:49:53 | <Peaker> | hmm I reinstalled cabal-install and its attempting to open a filename "\34" |
| 15:50:06 | <mmorrow> | heh |
| 15:50:13 | <mmorrow> | , "\34" |
| 15:50:14 | <lunabot> | "\"" |
| 15:50:30 | <EvilTerran> | "! |
| 15:50:35 | <Peaker> | strace's \34 |
| 15:50:37 | <Peaker> | I think its octal |
| 15:50:47 | <Peaker> | > chr (8*3+4) |
| 15:50:48 | <lambdabot> | '\FS' |
| 15:50:54 | <mmorrow> | hmm |
| 15:51:33 | <Peaker> | arg. I copied the .cabal file of cabal-install cause I wanted an executable and accidentally had it overwrite cabal exec - so I reinstalled it, and it broke it :( |
| 15:51:49 | <dcoutts> | doh! |
| 15:51:49 | <lambdabot> | dcoutts: You have 1 new message. '/msg lambdabot @messages' to read it. |
| 15:52:16 | <Peaker> | dcoutts: any idea why cabal-install is attempting to open a weird character as a file? |
| 15:52:20 | <mux> | mmorrow: unfortunately the build scripts don't seem to be in hackage-server |
| 15:52:29 | <dcoutts> | Peaker: nope, details? |
| 15:52:30 | <Peaker> | dcoutts: for any command, "cabal update", "cabal install ..", etc |
| 15:52:31 | <burp_> | anyone knows of haskell gsl bindings except of hmatrix? |
| 15:53:00 | <mmorrow> | mux: aww |
| 15:53:01 | <Peaker> | dcoutts: I just re-ran 0.6.2's bootstrap script, it rebuilt cabal and installed it, and now this happens |
| 15:53:14 | <paper_cc> | cat "~/.cabal/config" == ? |
| 15:54:01 | <mmorrow> | mux: i just remembered about this: http://darcs.haskell.org/hackage-scripts/ |
| 15:54:10 | <Peaker> | paper_cc: a big file |
| 15:54:15 | <mux> | mmorrow: I've been looking there too already :) |
| 15:54:23 | <mmorrow> | grr |
| 15:54:30 | <mux> | I should have said so, sorry |
| 15:54:44 | <mmorrow> | mux: what are you looking for in particular? |
| 15:55:03 | <Peaker> | paper_cc: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5183#a5183 |
| 15:55:07 | <mmorrow> | i use this haddock cmd and it works pretty nicely: |
| 15:55:09 | <mmorrow> | ./Setup haddock --hyperlink-source --hoogle --haddock-options=--html |
| 15:55:34 | <mux> | mmorrow: I want to see for sure how hackage generates haddock documentation, because some of the functions of my module will be unavailable on some platforms, and yet I'd like the docs for them to be generated |
| 15:55:37 | <mmorrow> | i wish i knew how to make the raw haddock command do that though |
| 15:55:58 | <mmorrow> | mux: hmm, probably ask dcoutts |
| 15:56:13 | <paper_cc> | Peaker: that's the default configuration =( |
| 15:56:15 | <mux> | I was pondering defining those functions to error calls, but this is only if I cannot find something better |
| 15:56:30 | <mux> | dcoutts: any idea about that haddock documentation generation problem? |
| 15:56:33 | <Peaker> | paper_cc: yeah, something's screwed up |
| 15:56:42 | <dcoutts> | paper_cc: my first suspicion would be that the thing got built wrong |
| 15:57:49 | <dcoutts> | mux: the code used by the doc build client is not available afaik, what is the problem exactly? |
| 15:57:58 | <paper_cc> | ACTION came up with a non-functional cabal-install twice but couldn't understand the problem |
| 15:58:10 | <mux> | dcoutts: I want to see for sure how hackage generates haddock documentation, because some of the functions of my module will be unavailable on some platforms, and yet I'd like the docs for them to be generated |
| 15:58:44 | <dcoutts> | mux: it'll just be doing something like runghc Setup haddock. The client is linux I think. |
| 15:58:47 | <mux> | ideally I'd get a nice __HADDOCK__ CPP macro defined, and at worse I gues I could define those functions to error calls in that case |
| 15:59:02 | <mux> | dcoutts: ok, thanks. any suggestions? |
| 15:59:31 | <Peaker> | dcoutts: what could make it build wrong? |
| 15:59:44 | <dcoutts> | mux: with haddock2 there's no way for your code to tell if it's being inspected by ghc vs by haddock |
| 16:00:01 | <dcoutts> | mux: unless you change the haddock hook |
| 16:00:28 | <dcoutts> | Peaker: messed up dependent packages |
| 16:00:36 | <Peaker> | dcoutts: :( |
| 16:00:37 | <mux> | mm, you mean I could costuomize my Setup.hs, so that the haddock hook ends up defining a CPP macro ? |
| 16:00:39 | <dcoutts> | Peaker: cosmic rays, evil curses etc |
| 16:00:54 | <mux> | if so, I guess that would be the cleanest way |
| 16:00:56 | <Peaker> | Now I'm gonna have to scrap everything and reinstall, probably |
| 16:01:15 | <dcoutts> | mux: probably, but it may be extremely ugly to do it |
| 16:01:23 | <mux> | heh |
| 16:01:27 | <mux> | dcoutts: ok, thanks again |
| 16:01:32 | <dcoutts> | np |
| 16:04:13 | <mux> | I think I'll go the easy way and define the functions to error "not available on this platform" when they don't exist :-P |
| 16:15:37 | <Peaker> | so what replaces old-locale? |
| 16:15:44 | <EvilTerran> | ... locale? |
| 16:15:47 | <Peaker> | @hoogle defaultLocale |
| 16:15:47 | <lambdabot> | No results found |
| 16:16:02 | <Peaker> | @hoogle locale |
| 16:16:02 | <lambdabot> | package old-locale |
| 16:16:02 | <lambdabot> | package setlocale |
| 16:16:11 | <Peaker> | no locale.. is it set-locale? |
| 16:16:37 | <zakwilson> | I'm trying to get some code to use multiple cores. Anybody care to inspect a trivial example? |
| 16:16:37 | <Saizan> | i think it's all in "time" now |
| 16:16:41 | <mux> | I dont think there's a new locale package yet |
| 16:16:46 | <mux> | Saizan: time depends on old-locale |
| 16:17:03 | <EvilTerran> | zakwilson, sure, hpaste.org it if it's more than a line or two |
| 16:17:08 | <zakwilson> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5184#a5184 |
| 16:18:41 | <EvilTerran> | zakwilson, what's the trouble? |
| 16:18:52 | <zakwilson> | It only uses one core. This machine has four. |
| 16:19:17 | <EvilTerran> | huh. it *looks* right to me |
| 16:19:56 | <zakwilson> | I had the same problem on a dual-core Linux machine, so it's pretty clear to me that I'm doing something wrong. |
| 16:20:09 | <zakwilson> | (Linux machine currently unavailable to test due to hardware failure) |
| 16:20:25 | <EvilTerran> | i'm guessing something to do with ghc or RTS flags |
| 16:20:49 | <jmcarthur> | zakwilson: how far are you letting it run? do you let it print out a few before giving up? |
| 16:20:56 | <zakwilson> | Everything I've found online suggests that this is exactly right. |
| 16:21:03 | <jmcarthur> | zakwilson: that is, how long does it take to calculate each value? |
| 16:21:09 | <zakwilson> | I haven't let it print any. I could try with smaller values. |
| 16:21:15 | <zakwilson> | I don't know. A long time. |
| 16:21:58 | <jmcarthur> | zakwilson: try shorter computations and maybe a list that isn't infinite |
| 16:22:00 | <EvilTerran> | zakwilson, have you tried a simpler example, say, "parAvg xs = let s = sum xs; l = genericLength xs in s `par` l `par` (s/l)"? |
| 16:22:14 | <paper_cc> | zakwilson: what if you change replicate 100 200 to [1..100]? (that is, different input values) |
| 16:22:16 | <jmcarthur> | i don't know how strategies treat infinite lists |
| 16:22:54 | <zakwilson> | I changed it to (replicate 100 40) and got results printed after a few seconds. Still only used one core. All results printed at once. |
| 16:22:58 | <EvilTerran> | just to see if it's compiling & running right, to narrow it down to either your flags or your code |
| 16:23:04 | <paper_cc> | zakwilson: several threads may detect that they're computing just the same values |
| 16:23:18 | <jmcarthur> | i'm doubtful about that one |
| 16:23:28 | <EvilTerran> | ACTION thinks paper_cc may actually have a point |
| 16:23:35 | <jmcarthur> | err, oh i see |
| 16:23:40 | <jmcarthur> | i interpreted the sentence wrong |
| 16:23:40 | <EvilTerran> | , vacuum (replicate 100 200) |
| 16:23:42 | <lunabot> | [(0,[1,2]),(1,[]),(2,[1,3]),(3,[1,4]),(4,[1,5]),(5,[1,6]),(6,[1,7]),(7,[1... |
| 16:23:52 | <zakwilson> | Just tested with a range. paper_cc seems to be correct. |
| 16:24:07 | <paper_cc> | EvilTerran: how does one decrypt this? |
| 16:24:12 | <EvilTerran> | every spine cell of that list points to the same number cell |
| 16:24:22 | <zakwilson> | It's now using 370% CPU. |
| 16:24:30 | <EvilTerran> | paper_cc, as a directed graph, (nodeId, successorNodes) |
| 16:24:59 | <EvilTerran> | (0,[1,2]) is the outermost (:), (1,[]) is the number cell, (2,[1,3]) is the next (:), ... |
| 16:25:10 | <EvilTerran> | , vacuum (repeat 100) |
| 16:25:12 | <lunabot> | [(0,[1,0]),(1,[])] |
| 16:25:28 | <EvilTerran> | [(:) cell, 100 cell] |
| 16:25:57 | <paper_cc> | EvilTerran: thanks |
| 16:26:39 | <paper_cc> | ACTION reads Haddock for GHC.Vacuum |
| 16:27:47 | <paper_cc> | , vacuum (repeat 100) ! 0 |
| 16:27:49 | <lunabot> | luna: Couldn't match expected type `a i e' |
| 16:28:03 | <paper_cc> | :t (!) |
| 16:28:05 | <lambdabot> | forall i e. (Ix i) => Array i e -> i -> e |
| 16:28:21 | <paper_cc> | , lookup 0 $ vacuum (repeat 100) |
| 16:28:24 | <lunabot> | Just [1,0] |
| 16:28:40 | <EvilTerran> | i guess the application of "fib" is getting fused with the "replicate", so the results are all stored in the same cell too. or something. |
| 16:33:33 | <hackagebot> | bsd-sysctl 1.0.2 |
| 16:34:17 | <duaneb> | hi haskellians |
| 16:34:30 | <duaneb> | what libs do I need to pass to LD to get it to link? |
| 16:34:52 | <duaneb> | (Note: I'm not actually trying to use ld, but I do want to know this) |
| 16:36:54 | <Peaker> | @hoogle makeRegex |
| 16:36:54 | <lambdabot> | No results found |
| 16:38:08 | <mux> | ACTION pets hackagebot |
| 16:49:44 | <duaneb> | so yea |
| 16:49:58 | <duaneb> | if anyone could tell me what libs ghc links into executables... |
| 16:50:21 | <Igloo> | If you run it with -v you'll see the linker invocation |
| 16:51:18 | <dmwit> | You could also use ldd on an already-built executable to see what libraries it's linked to. |
| 16:52:16 | <cdsmithus> | Is anyone able to actually install reactive? I'm having no luck so far. |
| 16:53:00 | <duaneb> | Igloo: thanks much! |
| 16:53:58 | <cdsmithus> | Currently, cabal-install is telling me that reactice depends on Stream, which depends on QuickCheck >= 2.0, while reactive itself needs QuickCheck < 2.0 |
| 16:54:49 | <dcoutts> | cdsmithus: if you can't find suitable versions, it's probably possible to hack it, ignore the warnings and do it anyway. |
| 16:55:24 | <dcoutts> | cdsmithus: you'd have to cabal unpack and cabal configure; cabal build; cabal install --only on the one that complains. |
| 16:55:28 | <duaneb> | ahh |
| 16:55:36 | <duaneb> | that's pretty scary O.O |
| 16:55:57 | <cdsmithus> | Thanks. |
| 16:56:37 | <dcoutts> | cdsmithus: it's unlikely that the package version clash would be a problem in practise unless both are actually exporting functions that use QC and you're trying to equate the two types or something |
| 16:57:36 | <cdsmithus> | And I'm sure they aren't... it's just QuickCheck, after all |
| 16:58:16 | <dcoutts> | cdsmithus: right, the problem is cabal doesn't know that. In other examples you'd really get type errors. |
| 17:00:16 | <cdsmithus> | So I've done the cabal unpack... it looks like I need to find the unpacked copy to configure? Any idea where that would be? |
| 17:00:46 | <dcoutts> | cdsmithus: it unpacks to a subdir with the name of the package, eg cd reactive-x.y |
| 17:00:56 | <cdsmithus> | Ah... silly me, not even checking the current directory |
| 17:00:59 | <cdsmithus> | Thank you! |
| 17:01:14 | <dcoutts> | ACTION should clarify the status message |
| 17:03:19 | <cdsmithus> | Great, that did it. Thanks, Duncan. |
| 17:04:12 | <paper_cc> | is it possible to replace GHC 6.10.1 with 6.10.3 without rebuilding every installed package? |
| 17:04:23 | <dcoutts> | paper_cc: no |
| 17:04:50 | <paper_cc> | oh |
| 17:05:49 | <paper_cc> | ACTION prepares himself for another recompilation of HOpenGL, Gtk2Hs and wxHaskell |
| 17:05:59 | <gwern> | paper_cc: ghc isn't very consistent with its binary stuff, y'see |
| 17:06:10 | <gwern> | just one of the things you'll have to get used to |
| 17:06:50 | <dcoutts> | in theory it's supposed to be between minor releases, but it's never been possible in practise because it checks .hi file versions down to the ghc minor version |
| 17:07:54 | <paper_cc> | dcoutts: can I just change the .hi headers? |
| 17:08:06 | <dcoutts> | paper_cc: no |
| 17:08:36 | <dcoutts> | paper_cc: well, if you knew the binary format and were prepared to risk it, it might be possible |
| 17:17:20 | <duaneb> | that's pretty scary O.O |
| 17:17:23 | <duaneb> | whoop |
| 17:18:45 | <mmorrow> | mauke: ping |
| 17:18:52 | <paper_cc> | ACTION nevertheless reads compiler/iface/BinIface.hs |
| 17:19:31 | <mauke> | mmorrow: pong |
| 17:20:30 | <mmorrow> | mauke: hey. i'm trying to write an x86 equiv of this x86_64 code that i have and am failing (it's similar to your hell.s in that it needs to pc). wanna take a look? :) |
| 17:20:32 | <mmorrow> | ACTION pastes |
| 17:21:09 | <mmorrow> | mauke: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2472#a2472 |
| 17:21:33 | <mmorrow> | i think for one i'm pushing the args in the wrong order |
| 17:22:08 | <mmorrow> | (but i tried switching that too and it segfaults as well, so i must be doing something(s) else wrong too) |
| 17:24:04 | <mmorrow> | mauke: here's C code to test it http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=2472#a2473 |
| 17:24:49 | <mauke> | yeah, parameter order is wrong |
| 17:24:50 | <mmorrow> | mapM_ (print . (+41)) [0..7] |
| 17:29:02 | <mauke> | mmorrow: hah, 22 lines of compiler diagnostics |
| 17:29:43 | <mmorrow> | hehe |
| 17:35:55 | <jrib> | I looked through http://www.haskell.org/haskellwiki/Books but can I get a recommendation for a book for someone comfortable with abstract math and other programming languages and no real prior experience with haskell? |
| 17:36:50 | <mauke> | mmorrow: that whole scheme doesn't work |
| 17:36:59 | <mmorrow> | mauke: gah, apparently it's segfaulting in memcpy |
| 17:37:04 | <wli> | I never learned Haskell from books. Someone else chime in here. |
| 17:37:04 | <babilen> | i enjoy reading Real World Haskell - but it is the first contact i have with Haskell so i can't comment on other books |
| 17:37:05 | <mmorrow> | (according to gdb) |
| 17:37:09 | <mmorrow> | mauke: oh? |
| 17:37:26 | <mauke> | wait, what are your semantics |
| 17:37:46 | <jrib> | wli: did you just read documentation online and dive in that way? |
| 17:37:53 | <mauke> | mmorrow: do you only support functions of a single argument? |
| 17:37:59 | <wli> | jrib: And papers. |
| 17:38:12 | <wli> | jrib: esp. springschool95.ps |
| 17:38:21 | <jrib> | wli: hmm, what's a good source for haskell papers? Would I find them on arxiv? |
| 17:38:26 | <mauke> | or is that two arguments |
| 17:38:36 | <dmwit> | jrib: The Gentle Introduction is nice (though definitely not book length). |
| 17:38:49 | <pejo> | jrib, most authors have them on their homepage. |
| 17:38:52 | <mmorrow> | mauke: so the stub function take an mmapped chunk of memory, then copies into it machine code + storage for a functionptr and a long, which when called will call that embedded function with the embedded long as first arg, and the arg that it was called with as second arg |
| 17:39:02 | <wli> | jrib: I used the SEL-HPC functional programming archive when it was still around. I don't know that there is a centralized source anymore. |
| 17:39:11 | <dmwit> | jrib: People also report great success with YAHT (unfinished, but possibly book length), LYAH (mid-size), and RWH (a very nice and recent book). |
| 17:39:14 | <mauke> | mmorrow: ok, so the real function will always take two args |
| 17:39:21 | <mauke> | hmm, this is doable |
| 17:39:22 | <mmorrow> | mauke: yes |
| 17:39:42 | <mmorrow> | mauke: totally, the x86_64 version seems to work ok |
| 17:39:49 | <dmwit> | jrib: As for papers, the one that got me hooked on Haskell was SPJ's paper on composable contracts. |
| 17:40:01 | <mauke> | mmorrow: I'm ignoring that, I don't know x86_64 :-) |
| 17:40:14 | <mmorrow> | mauke: heh |
| 17:40:32 | <dmwit> | jrib: http://research.microsoft.com/en-us/um/people/simonpj/papers/financial-contracts/contracts-icfp.htm # this one |
| 17:41:00 | <mmorrow> | mauke: the part of `stub' that actually executes when it's called is: |
| 17:41:43 | <mmorrow> | stub buf = let asm = [|.... f: .long 0, a: .long 0 ...|] in memcpy buf asm (length asm) |
| 17:41:50 | <dmwit> | Wow, you know what's the worst default ps viewer ever? GIMP |
| 17:42:07 | <dmwit> | Screw you, sysadmin, whoever you are. (Aw, crap, it's me.) |
| 17:42:12 | <mmorrow> | mauke: so i think what's happening is that i'm not passing the arg to stub along to memcpy correctly |
| 17:42:13 | <shapr> | whoops |
| 17:42:37 | <mauke> | mmorrow: yes, that's one of the problems |
| 17:42:50 | <mauke> | I'm working on it :-) |
| 17:42:55 | <mmorrow> | weee :) |
| 17:44:49 | <Philonous> | Is it a fair assessment to say monads encode side effects of some sort? Because you can't have direct side effect you store a description of it and the bind operator will "perform" it for you. |
| 17:45:10 | <dons> | the system performs it for you. |
| 17:45:11 | <gwern> | they can do that, but what are the side effects of the maybe or list monads? |
| 17:45:50 | <Phyx-> | lol, can UndecidableInstances cauze ghc to go into an endless loop when compiling? |
| 17:46:01 | <Philonous> | In maybe you can either continue the computation (Just) or abort it (Nothing), Either lets you either continue or abort with an error message |
| 17:46:20 | <jrib> | dmwit, pejo, wli: thank you for your suggestions |
| 17:46:50 | <gwern> | Phyx-: extensions can do that |
| 17:47:30 | <EvilTerran> | Phyx-, yes, hence the name "undecidable" |
| 17:47:54 | <Philonous> | dons: I meant monads in general. If you write your own monad instance your bind operator will handle the side effects, does it not? |
| 17:48:04 | <EvilTerran> | Phyx-, although i seem to recall the typechecker has a fixed recursion depth limit |
| 17:48:13 | <Philonous> | dons: In the case of IO the bind operator just does it "magically" ;) |
| 17:48:34 | <Phyx-> | EvilTerran: i figured asmuch, I think i also know why it's doing it, i was just blindly following ghc's suggestions without thinking it throught :P |
| 17:48:47 | <Phyx-> | EvilTerran: well, it sucked up to 2gb of memory before i killed it |
| 17:50:12 | <dons> | Philonous: no, bind has nothing to do with it. it doesn't 'handle the effects' |
| 17:50:37 | <dons> | bind helps set up a dependency from one function to another, and lets you bind the result of one computation for use later |
| 17:51:07 | <RLa> | is there patch for haddock that allows unicode or html entities in comments? |
| 17:51:33 | <gwern> | haddock doesn't handle unicode? |
| 17:52:10 | <dblick> | I'm trying to figure out the Bananas and Barbed wire paper. It seems that ana = foldr and cata = Data.Lists.unfoldr; are there standard equivalents of hylo and para? |
| 17:52:20 | <RLa> | gwern, no |
| 17:52:39 | <gwern> | huh. could it be using the standard IO functions and mangling the unicode? |
| 17:52:40 | <RLa> | it just strips out some non-ascii chars and screws up others |
| 17:53:04 | <gwern> | hm. that does sound like the IO functions |
| 17:53:07 | <dmwit> | dblick: buildr is likely to be one of them, though I don't actually know what a hylo- or paramorphism is. |
| 17:53:17 | <RLa> | no idea about mangling, manual says in clear words: "ASCII only" |
| 17:53:40 | <EvilTerran> | buildr? |
| 17:54:21 | <gwern> | line 449 of Main.hs: 'str ← readFile filename' |
| 17:54:28 | <gwern> | that could be it |
| 17:54:51 | <RLa> | gwern, is that for me? |
| 17:54:59 | <gwern> | RLa: yeah |
| 17:56:08 | <RLa> | i also have some mess here, i update haddock, during update said it's 2.4.2 but haddock -V gives 2.3.0 |
| 17:56:21 | <dmwit> | buildr has a weird type, and I always get it wrong, and I can't find it now... |
| 17:56:25 | <dmwit> | Something like |
| 17:56:38 | <dmwit> | :t (:) |
| 17:56:39 | <lambdabot> | forall a. a -> [a] -> [a] |
| 17:57:15 | <dmwit> | gah |
| 17:58:00 | <dcoutts> | @seen Heffalump |
| 17:58:01 | <lambdabot> | Heffalump is in #darcs and #haskell. I last heard Heffalump speak 2h 12m 7s ago. |
| 17:58:44 | <dmwit> | buildr :: (forall b. (a -> b -> b) -> b -> b) -> [a] -- or something like that |
| 17:58:59 | <dmwit> | buildr f = f (:) [] |
| 17:59:29 | <dmwit> | Let's see... |
| 17:59:30 | <dmwit> | :t foldr |
| 17:59:31 | <lambdabot> | forall a b. (a -> b -> b) -> b -> [a] -> b |
| 18:00:03 | <byorgey> | dblick: you've got those backwards, actually, foldr is the catamorphism for lists and unfoldr is the anamorphism |
| 18:00:42 | <byorgey> | 'cata' meaning 'down' (fold a data structure 'down' into a summary value) and 'ana' meaning 'up' (build 'up' a data structure from a seed) |
| 18:00:52 | <dblick> | byorgey, oops, yes, that's right. and it looks like hylo is composition of cata para? |
| 18:01:18 | <byorgey> | cata ana. |
| 18:02:00 | <dblick> | oops. right. |
| 18:03:07 | <byorgey> | paramorphisms are generalizations of catamorphisms. |
| 18:05:28 | <Philonous> | dons: Assuming that a side effect is a change of context, doesn't bind handle them insofar, as it applies a function in the current context, takes it's return values (which in the monadic case are descriptions of contexts) and merges them together to a new context? |
| 18:08:37 | <jaredj> | hello all. open financial exchange (ofx) is an sgml-based language for financial facts (e.g. bank statements). if i write a parser for it, does it rightly go under Text, Data, Codec? |
| 18:09:45 | <sm> | go jaredj! I need that |
| 18:10:29 | <sm> | I'd guess Data |
| 18:10:33 | <byorgey> | jaredj: Data is usually for data structures, so not that I think |
| 18:10:39 | <sm> | doh |
| 18:10:51 | <byorgey> | I mean, on some level it doesn't really matter that much. |
| 18:10:51 | <sm> | Finance ? |
| 18:12:03 | <byorgey> | jaredj: the other two sound fine. |
| 18:12:41 | <dons> | Philonous: yeah, that's correct. |
| 18:12:59 | <dons> | e.g. getChar :: World -> (World , Char) |
| 18:13:34 | <shapr> | ACTION boings cheerfully |
| 18:16:35 | <gwern> | jaredj: I'd go with text. if it's sgml-based, then it's akin to html/xhtml, which are under text iirc |
| 18:16:59 | <gwern> | (Language. would be my second choice; then codec, then data) |
| 18:17:36 | <dons> | if it is full support for the language (parsing, pretty printing, etc) Language.* |
| 18:17:41 | <dons> | else Text.* |
| 18:18:08 | <gwern> | dons: come to think of it, is there any description of the hierarchy anywhere? |
| 18:18:14 | <fracture> | is there an assertion function in haskell? |
| 18:19:04 | <dons> | fracture: yep, assert |
| 18:19:06 | <gwern> | @hoogle assert |
| 18:19:06 | <lambdabot> | Control.Exception assert :: Bool -> a -> a |
| 18:19:06 | <lambdabot> | Test.HUnit.Base assert :: Assertable t => t -> Assertion |
| 18:19:06 | <lambdabot> | Test.HUnit.Base class Assertable t |
| 18:19:08 | <dons> | gwern: yep. |
| 18:19:20 | <dons> | but it was made radically obsolete by hackage |
| 18:19:36 | <fracture> | huh |
| 18:19:40 | <gwern> | ah. that makes sense... the categories in hackage could use a little cleanup, 'tis true |
| 18:19:42 | <dons> | gwern: see 'proposals' http://haskell.org/haskellwiki/Applications_and_libraries |
| 18:19:42 | <fracture> | does it throw an exception if the assertion fails? |
| 18:19:49 | <dons> | si. |
| 18:19:50 | <fracture> | I'd like something that terminates the program |
| 18:20:05 | <fracture> | using exceptions for assertions is a Bad Idea |
| 18:20:10 | <fracture> | makes exception safety difficult |
| 18:20:22 | <dons> | Prelude> GHC.Base.assert (True == False) $ "hey" |
| 18:20:23 | <dons> | "*** Exception: <interactive>:1:0-14: Assertion failed |
| 18:20:24 | <fracture> | (at least in a language like C++... I haven't thought about how that might work over in a pure functional setting) |
| 18:20:37 | <gwern> | fracture: personally, I'd just do something like 'when foo $ error 'impossible!' or 'if !foo then error 'impossible' else regular stuff'; about as long as importing C.E and using assert |
| 18:20:42 | <dmwit> | How do you propose to terminate the program in a principled way without exceptions? |
| 18:20:44 | <dons> | i think async exceptions in haskell are probably a bit different to what you're thinking of. |
| 18:20:53 | <gwern> | dons: so it's not much different than an if with an error call |
| 18:20:53 | <fracture> | gwern: ok |
| 18:20:54 | <gwern> | @src assert |
| 18:20:55 | <lambdabot> | Source not found. Your mind just hasn't been the same since the electro-shock, has it? |
| 18:21:01 | <gwern> | @src Control.Exception.assert |
| 18:21:01 | <lambdabot> | Source not found. The more you drive -- the dumber you get. |
| 18:21:03 | <dons> | gwern: but note the source locations |
| 18:21:08 | <dmwit> | gwern: That's still an exception, and it doesn't give you line number information... |
| 18:21:13 | <dons> | also, ghc will optimize asserts out |
| 18:21:17 | <dons> | (there's a flag to control that) |
| 18:21:25 | <fracture> | is there no library function to call abort()? |
| 18:21:30 | <dons> | so yes, conditionals, with some pragmatic infrastructure |
| 18:21:33 | <dons> | fracture: exitWith |
| 18:21:41 | <gwern> | optimize asserts out? sounds kind of dangerous |
| 18:21:42 | <dmwit> | fracture: Sure, there's an IO action for that. |
| 18:21:44 | <fracture> | probably calls exit, eh? |
| 18:21:47 | <dons> | but if you really really just want to terminate the (unix) process, there's the unix library |
| 18:21:53 | <fracture> | abort() will leave a core dump on most OSes |
| 18:22:09 | <dons> | best practice for exit conditions is exitWith, if you want to produce a core dump, poke around in the unix library (exitImmediately) |
| 18:22:22 | <fracture> | hrm |
| 18:22:52 | <fracture> | seems like a hole in the library if you have to use an OS-specific lib to terminate the program that way |
| 18:23:02 | <pjdell> | i know this is off topic but when upgrading ram, do i need to match mhz from my old ram to my new ram.... so old ram is ddr2 667, new ram needs to be ddr2 667? |
| 18:23:10 | <fracture> | is the unix lib implemented for win32? |
| 18:23:10 | <dons> | fracture: to produce a portable core dump? |
| 18:23:18 | <shapr> | pjdell: Or faster, but it depends on the chipset on your mobo |
| 18:23:21 | <gwern> | fracture: there's some OS-neutral way to produce core dumps? |
| 18:23:25 | <dons> | if it is posix functionality, it may be in the portable base library |
| 18:23:29 | <fracture> | no, to terminate as a failure and do whatever is right in an OS-specific sense |
| 18:23:36 | <shapr> | pjdell: Come to #haskell-blah |
| 18:23:37 | <fracture> | abort() is part of standard C, for example |
| 18:23:38 | <dons> | oh, then use exitWith |
| 18:23:46 | <dons> | fracture: exitWith is how you terminate a haskell program portably |
| 18:23:48 | <dons> | in System.Exit |
| 18:23:49 | <copumpkin> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5185#a5185 whee |
| 18:23:53 | <gwern> | yeah, exitWith would be fine. I don't think core dumps are even desirable in general |
| 18:24:03 | <fracture> | no, they are desirable... |
| 18:24:12 | <fracture> | if your program terminates due to improper programmer assumptions |
| 18:24:40 | <Cale> | Are you seriously going to do something with a core dump of a Haskell program though? |
| 18:24:43 | <gwern> | so the user now has these big useless binary files laying around. very friendly thing to do... |
| 18:24:43 | <fracture> | I dunno what it's like to try to debug a ghc-compiled program's core though.... maybe it's useless anyway |
| 18:24:50 | <Cale> | I don't think we have any tools which apply to them. |
| 18:24:54 | <dons> | for experts, anyway |
| 18:25:05 | <dons> | would be better to use exitWith and then use the ghci debugger |
| 18:25:09 | <fracture> | gwern: the user can ulimit -c 0 if they don't want cores |
| 18:25:10 | <dons> | or get a stack trace |
| 18:25:26 | <dons> | .... why is your haskell program going to dump core though ... |
| 18:25:32 | <fracture> | (or if they are on windows, they don't get cores by default anyway) |
| 18:25:55 | <gwern> | fracture: oh, that's even better? make them understand and use an obscure option to an obscure command to avoid getting something they have no use for and which wastes their resources and time? |
| 18:25:59 | <gwern> | epicycles... |
| 18:26:11 | <dons> | let's step back a bit: what error case in your program do you think will be handled usefully via a core dump? |
| 18:26:30 | <fracture> | let's say you have a function taking a sorted list as an argument |
| 18:26:32 | <dons> | since the usual C-like things aren't possible, thanks to soundness of the type system. |
| 18:26:39 | <fracture> | and it's a precondition violation to call it with an unsorted list |
| 18:26:49 | <fracture> | in debug, I want to check the precondition |
| 18:27:00 | <dons> | right. so an 'assert' call is appropriate |
| 18:27:05 | <dons> | for runtime invariants you've not ruled out via the type system |
| 18:27:19 | <dons> | that will then let you analzye the code later in the ghci debugger |
| 18:27:33 | <dons> | you *do not want to dump core* to analyze that though. it will not be helpful. |
| 18:27:37 | <fracture> | ok; sounds like it's just different than C |
| 18:27:49 | <fracture> | the problem is, I don't want to be able to trap the assertion's exception |
| 18:27:53 | <dons> | core dumps are really designed with gdb in mind :) |
| 18:28:01 | <fracture> | (I don't know enough about the error system to know if that is a problem) |
| 18:28:11 | <dons> | sure. that's fine. use assert and don't catch exceptions of that kind. |
| 18:28:17 | <dons> | you'll work out how to do that easily enough |
| 18:28:18 | <duaneb> | do any of these (http://haskell.org/haskellwiki/Research_papers/Domain_specific_languages#Hardware_design) describe the description of hardware in haskell? |
| 18:28:26 | <dons> | duaneb: yes. |
| 18:28:34 | <fracture> | does anyone every code to catch all exception types? |
| 18:28:41 | <dons> | i hope not |
| 18:28:43 | <fracture> | in library stuff, etc? |
| 18:28:52 | <dons> | in libraries, unlikely |
| 18:28:55 | <fracture> | (common practice in C++, and an essential part of exception-safe programming) |
| 18:28:58 | <fracture> | ok |
| 18:29:03 | <dons> | you can write such a handler though |
| 18:29:09 | <fracture> | guessing it's just different (I'll learn up on this at some point) |
| 18:29:12 | <dons> | library functions will indicate which errors they handle |
| 18:29:12 | <sclv> | fracture: people do have handlers that catch and rethrow all exceptions |
| 18:29:20 | <sclv> | including in Control.Exception -- for cleanup and such. |
| 18:29:23 | <fracture> | sclv: right, that's what I'm worried about |
| 18:29:39 | <eivuokko> | You rarely catch all exception in C++, without rethrowing. |
| 18:29:50 | <fracture> | let me think a little more about how exception safety works in a pure functional setting though |
| 18:30:02 | <dons> | fracture: i think you should just start programming :) these worries will go away once you work out type safe programming :) |
| 18:30:04 | <fracture> | eivuokko: right; but if there was a precondition violation, you don't want to throw an exception at all in C++ |
| 18:30:11 | <sclv> | as for generally catching all exceptions -- I think it makes sense for component systems like servers, except even then there are a few that aren't really generally recoverable from. |
| 18:30:13 | <eivuokko> | Also, ghc has async exceptions, which change things a bit. |
| 18:30:32 | <SamB> | fracture: you mean, like, bracket ? |
| 18:30:43 | <sclv> | ?hoogle bracket |
| 18:30:44 | <lambdabot> | Control.Exception bracket :: IO a -> a -> IO b -> a -> IO c -> IO c |
| 18:30:44 | <lambdabot> | Control.Exception bracket_ :: IO a -> IO b -> IO c -> IO c |
| 18:30:44 | <lambdabot> | Control.Exception bracketOnError :: IO a -> a -> IO b -> a -> IO c -> IO c |
| 18:30:45 | <fracture> | so... it seems like exception safety is a little different because of the lack of mutable state |
| 18:31:11 | <sclv> | fracture: exceptions themselves have funny semantics because of laziness, really. |
| 18:31:32 | <dons> | fracture: btw, ch19 of real world haskell covers how exceptions work. another great reference is 'tackling the awkward squad' |
| 18:31:33 | <sclv> | you have to think differently about them, but you'll get the hang soon enough. |
| 18:31:39 | <fracture> | dons: I'll check it out |
| 18:31:41 | <duaneb> | dons: lava? |
| 18:31:42 | <dons> | which describes threads, locks, exceptions in haskell, you'll work it out. |
| 18:31:44 | <SamB> | fracture: personally, I'd think violated preconditions should lead DIRECTLY to an exception, if it wouldn't just give you the wrong answer ... |
| 18:31:49 | <dons> | duaneb: lava, yes. (its on hackage). |
| 18:32:01 | <fracture> | SamB: maybe in haskell (I don't know yet), in C++ that's wrong though |
| 18:32:03 | <gwern> | RLa: did you fix haddock's unicode issues? |
| 18:32:05 | <dons> | duaneb: there's some commercial ones (cryptol, bluespec). i think 'wired' is another open source one. |
| 18:32:07 | <monadic_kid> | "exception safe code" is not about trying to catch all thrown exceptoins |
| 18:32:15 | <fracture> | monadic_kid: I know |
| 18:32:26 | <monadic_kid> | so why did you make that statement? |
| 18:32:29 | <fracture> | I didn't |
| 18:32:33 | <dons> | fracture: play around with Control.Exception a bit, you'll get how it works |
| 18:32:42 | <SamB> | bracket sorta catches all errors ... but it releases them after cleaning up |
| 18:32:47 | <SamB> | er. |
| 18:32:47 | <fracture> | "exception safety" refers to a very specific set of coding practices |
| 18:32:52 | <SamB> | s/error/exception/ |
| 18:32:54 | <fracture> | similar to "thread safety", or whatever other safety |
| 18:33:09 | <jkl2> | I'm getting 'multiple definition' errors related to the 'process' package when running 'ghc --make'. The problem is that ld is trying to link in both Ubuntu's version and my local version. I don't know why both are being linked in. What should I do? |
| 18:33:10 | <monadic_kid> | fracture: i'm aware of what exception safe code refers to thanks |
| 18:33:25 | <fracture> | then maybe you can help me understand how it works in haskell? |
| 18:33:28 | <SamB> | fracture: such as, not having the program totally crash just because an exception got thrown from inside ? |
| 18:33:41 | <sclv> | fracture: also, when you're not worried about speed with all capitals, then often its better to write total functions that return Maybe values or Either values than that throw exceptions. |
| 18:33:50 | <fracture> | SamB: no; it has to do with reasoning about changes in program state when exceptions are thrownm to ensure all invariants still hold |
| 18:33:59 | <dons> | fracture: best to learn by doing, rather than IRC though. you'll just get confused without some concrete code to work with. |
| 18:33:59 | <SamB> | fracture: ah |
| 18:34:03 | <fracture> | languages like java and C# do it very poorly (often not at all) |
| 18:34:13 | <dons> | fracture: http://book.realworldhaskell.org/read/error-handling.html |
| 18:34:14 | <SamB> | the best way to avoid that is to not have global state when you can help it |
| 18:34:16 | <fracture> | and in python it is literally impossible to write exception safe code |
| 18:34:38 | <fracture> | C# too IIRC (there are async thread abort exceptions, which prevent you from writing functions that are guaranted not to throw) |
| 18:34:45 | <monadic_kid> | i'm not aware of any RAII like idioms in haskell |
| 18:34:47 | <SamB> | fracture: I think you're exaggerating a bit wrt python ... |
| 18:34:48 | <dmwit> | fracture: One thing some people do for invariants is to invent a newtype, hide the constructor, and write a "smart constructor" that first ensures the invariant holds, then constructs the newtype. |
| 18:34:48 | <sclv> | haskell's exception mechanisms are mostly really nice, except for when you have to reason about block and unblock... |
| 18:34:48 | <fracture> | dons: thanks, was just about to start reading that |
| 18:35:05 | <SamB> | monadic_kid: why need RAII when we have bracket ? |
| 18:35:10 | <fracture> | monadic_kid: sounds like bracket is somewhat like it? |
| 18:35:23 | <fracture> | (bracket is like C++ scopeguard) |
| 18:35:24 | <dons> | fracture: no, static guarantee the condition holds dynamically. |
| 18:35:35 | <dons> | sort :: [a] -> Sorted [a] |
| 18:35:41 | <dmwit> | fracture: For example: module SortedList (sortedList) where { newtype SortedList a = SortedList { toList :: [a] }; sortedList = SortedList . sort } |
| 18:35:41 | <dons> | then you write functions of type Sorted [a] -> ... |
| 18:35:54 | <dons> | and its not possible to be passed an unsorted list, assuming your smart constructor is correct. |
| 18:35:54 | <fracture> | dmwit: ah that is very nice |
| 18:36:03 | <SamB> | or in Coq, you could actually *prove* the invariants to hold |
| 18:36:04 | <sclv> | bracket still interacts funny with lazy IO though, of course. |
| 18:36:17 | <fracture> | (could get tedious for certain types of preconditions, but may be quite useful for some other ones) |
| 18:36:21 | <dons> | so you can rule out a lot of 'asserts' statically --> leaning on the type system is a core part of becoming a good haskell programmer |
| 18:36:23 | <SamB> | sclv: what doesn't ? |
| 18:36:29 | <fracture> | (and static checking is almost always better) |
| 18:36:35 | <SamB> | lazy IO may just not be the right way to do it :-( |
| 18:36:44 | <fracture> | anyway I'll go read the exception chapter |
| 18:36:45 | <sclv> | plus you can pass the generated handle right out of the bracket statement if you are irritating and evil (which is in essence what lazy io does) |
| 18:36:54 | <dmwit> | fracture: Yes, it can get a little tedious for some conditions. |
| 18:37:01 | <dons> | sclv: do you think bracket/handle should be in rnf? |
| 18:37:30 | <dons> | (similar issue with Chan, MVars, IORefs, other things that say something about the scope/timeing/evaluatedness) |
| 18:37:33 | <sclv> | dons: not really, i think. but maybe there should just be more documentation, and strict variants? |
| 18:37:38 | <pjdell> | l |
| 18:37:48 | <dons> | i guess strict variants are the usual practice |
| 18:37:54 | <dons> | yes, that seems reasonable. |
| 18:38:02 | <eu-prleu-peupeu> | hello haskellers |
| 18:38:02 | <dons> | (possibly even by default..) |
| 18:38:05 | <eu-prleu-peupeu> | hi dons |
| 18:38:35 | <sclv> | sometimes i want to write thunks to chans, so that i can force evaluation elsewhere, for example. |
| 18:38:36 | <SamB> | yeah, like what the heck is with foldl ? |
| 18:38:37 | <malosh> | Hi. Is there a way to define a constant empty MArray in a program, like in ocaml with (let a=[| |]) ? I have a complicated record type for which I want to provide a default |
| 18:38:54 | <SamB> | I think foldl should be deprecated in the next Haskell standard ... |
| 18:38:58 | <SamB> | replaced with foldl'' |
| 18:39:03 | <dmwit> | fracture: On the other hand, it's also a pretty handy way to deal with some invariants. There's a great example in xmonad; the X library doesn't distinguish between an Int pointing at a window and an Int pointing at (say) a screen, so xmonad uses newtypes to make sure that those two types of Int never switch places... |
| 18:39:14 | <SamB> | then, in the one after that, we can alias foldl' as foldl ... |
| 18:39:15 | <sclv> | s/thunks/unevaluated expressions/ (precision police) |
| 18:39:24 | <roconnor> | malosh: MArray is more like a function than an actual object. |
| 18:39:41 | <fracture> | dmwit: yeah, that sounds like a nice use of static typing |
| 18:40:16 | <dons> | we followed a general rule of moving invariants into the type system, where possible, in xmonad. everything else was checked with quickcheck |
| 18:40:22 | <dons> | and then coverage analysis to back that up. |
| 18:40:33 | <fracture> | what's quickcheck? |
| 18:40:42 | <dmwit> | ?check \x y -> x + y == y + x |
| 18:40:43 | <lambdabot> | "OK, passed 500 tests." |
| 18:40:43 | <eu-prleu-peupeu> | hey dons, im ripping the xmonad code for a project of mine :) hope theres no problem with it |
| 18:40:46 | <SamB> | dons: so has anyone rewritten xmonad in Coq yet ? |
| 18:40:47 | <dons> | automatic test generatoin based on type information |
| 18:40:54 | <dmwit> | fracture: It's a type-directed randomized tester. |
| 18:41:02 | <dons> | eu-prleu-peupeu: will be interesting to see how you go. do let me know. |
| 18:41:03 | <SamB> | eu-prleu-peupeu: did you not read COPYING ? |
| 18:41:03 | <fracture> | ah sounds nice |
| 18:41:14 | <RLa> | it fails on basic rule of testing that tests must be repeatable |
| 18:41:25 | <dons> | RLa: it is repeatable |
| 18:41:28 | <roconnor> | SamB: http://www.haskell.org/pipermail/xmonad/2009-May/007881.html |
| 18:41:29 | <RLa> | oh |
| 18:41:30 | <dons> | RLa: you feed a seed in. |
| 18:41:30 | <eu-prleu-peupeu> | SamB, im "rewritting" it for a different purpose, most of the architecture stays the same though :) |
| 18:41:31 | <dmwit> | ?check \n -> length (replicate n ()) == n |
| 18:41:33 | <lambdabot> | "Falsifiable, after 0 tests:\n-1\n" |
| 18:41:51 | <dmwit> | Oh, cool, there's a great example of a property I thought would be true. |
| 18:42:03 | <dons> | heh |
| 18:42:23 | <SamB> | dmwit: you just need a better type for it ;-P |
| 18:42:27 | <dmwit> | ?check \n -> n > 0 ==> length (replicate n ()) == n |
| 18:42:28 | <lambdabot> | No instance for (QuickCheck-1.1.0.0:Test.QuickCheck.Testable |
| 18:42:28 | <lambdabot> | ... |
| 18:42:29 | <roconnor> | dons: Do you really use seeds when QuickChecking xmonad? |
| 18:42:42 | <dmwit> | ?check \n -> (n > 0) ==> (length (replicate n ()) == n) |
| 18:42:43 | <lambdabot> | No instance for (QuickCheck-1.1.0.0:Test.QuickCheck.Testable |
| 18:42:43 | <lambdabot> | ... |
| 18:42:46 | <dmwit> | huh |
| 18:42:57 | <dons> | roconnor: no, as i want to search more of the search space on each run |
| 18:42:57 | <roconnor> | dmwit: ==> is busted in lambdabot |
| 18:43:01 | <dmwit> | Oh, okay. |
| 18:43:03 | <dons> | but e.g. ghc uses a fixed seed |
| 18:43:14 | <roconnor> | oh interesting |
| 18:43:35 | <hatds> | can use an 'if' I suppose |
| 18:43:45 | <SamB> | something to do with SmallCheck, I expect ? |
| 18:43:46 | <dmwit> | fracture: There's also smallcheck, which is similar, but exhaustive. Naturally, it only works well for small, finite types... ;-) |
| 18:44:00 | <SamB> | ?scheck \n -> (n > 0) ==> (length (replicate n ()) == n) |
| 18:44:01 | <lambdabot> | No instance for (QuickCheck-1.1.0.0:Test.QuickCheck.Testable |
| 18:44:01 | <lambdabot> | ... |
| 18:44:07 | <copumpkin> | http://hpaste.org/fastcgi/hpaste.fcgi/view?id=5187#a5187 naive factorial vs. primop factorial :P |
| 18:44:14 | <roconnor> | I wonder if it is better to quickcheck 500 tests than repeatably test 1 test. |
| 18:44:17 | <SamB> | hmm, no ... |
| 18:44:29 | <SamB> | roconnor: probably neither is that great |
| 18:44:29 | <dons> | there's a couple of model-based generators for quickcheck now too |
| 18:44:30 | <roconnor> | possibly false dichotomy |
| 18:44:34 | <dons> | and one that hooks up prologo |
| 18:44:48 | <sclv> | ?check \n -> n <=0 || length (replicate n ()) == n |
| 18:44:50 | <lambdabot> | "OK, passed 500 tests." |
| 18:44:53 | <SamB> | roconnor: both is better, but I'd think you'd want at least 3 or 4 pre-selected cases |
| 18:44:53 | <paper_cc> | does GADT syntax for associated types work in GHC 6.10.3? (I looked at the ticket but it doesn't mention if the changes were committed to STABLE) |
| 18:45:07 | <SamB> | roconnor: (selected on the basis of having failed in the past, possibly) |
| 18:45:11 | <dmwit> | I remember reading something about quickcheck getting a way to minimize test cases... did anything ever come of that? |
| 18:45:24 | <dons> | yes, it supports shrinking in QC 2 |
| 18:45:27 | <dons> | and has done for a while. |
| 18:45:30 | <roconnor> | what I almost like more about QuickCheck is that you actually get write out Pi_1 formula giving specifications. |
| 18:45:33 | <SamB> | reminds me of lazy smallcheck ... |
| 18:45:41 | <roconnor> | that's even more important than checking them IMHO |
| 18:46:44 | <dons> | stating all those invariants is the main thing, yes. they specify your program |
| 18:46:59 | <dons> | then you get to choose whether to enforce them via the type system, an external static analysis, a runtime check, or testing |
| 18:47:13 | <dons> | but first you need the properties. |
| 18:47:26 | <roconnor> | often it is hard to enforce them via the type system. |
| 18:47:41 | <dmwit> | ACTION senses a circle in the conversation |
| 18:47:45 | <roconnor> | and probably often hard to do a runtime check |
| 18:48:04 | <roconnor> | and you can only test instaces. |
| 18:48:09 | <SamB> | they might all 4 be hard |
| 18:48:12 | <roconnor> | go static analysis! |
| 18:48:36 | <dons> | depends on how much IO I think. |
| 18:48:54 | <dmwit> | Yeah, it's hard to quickcheck Gtk interfaces. |
| 18:48:59 | <Baughn> | ACTION wonders if anyone has looked at using AOP/FOP in haskell |
| 18:49:13 | <duaneb> | huh |
| 18:49:13 | <duaneb> | so |
| 18:49:20 | <roconnor> | oh ya. I was only talking about quickcheck properties |
| 18:49:22 | <duaneb> | I did `cabal install chalmers-lava2000` |
| 18:49:25 | <duaneb> | and it installed |
| 18:49:29 | <duaneb> | but neither I nor ghc can find it |
| 18:49:35 | <roconnor> | which probably doesn't encompass all properties you want to check |
| 18:49:40 | <dmwit> | duaneb: ghc-pkg list? |
| 18:49:59 | <dmwit> | duaneb: (I'm guessing it's installed locally, and you're trying to compile something using the global package list.) |
| 18:49:59 | <roconnor> | @seen Cale |
| 18:49:59 | <lambdabot> | Cale is in #haskell-in-depth, #ghc, #haskell-overflow and #haskell. I last heard Cale speak 25m 8s ago. |
| 18:50:15 | <roconnor> | Cale: what would it take to get ==> working in @check again? |
| 18:50:58 | <Baughn> | @tell frwmanners [..no version of filterE could work with...] <-- Could you expand on this? |
| 18:50:59 | <lambdabot> | Consider it noted. |
| 18:51:03 | <dmwit> | ?ask Cale what it would take to get ==> working in @check again |
| 18:51:03 | <lambdabot> | Consider it noted. |
| 18:51:20 | <duaneb> | yep |
| 18:51:26 | <duaneb> | dmwit: it lists it as chalmers-lava2000-1.0.2 |
| 18:51:41 | <dmwit> | duaneb: But does it list it in the global package list or in the local package list? |
| 18:52:05 | <duaneb> | ahh, it's Lava200 |
| 18:52:39 | <duaneb> | dmwit: local |
| 18:54:25 | <dmwit> | duaneb: Cool, and how are you compiling whatever it is that uses it? |
| 18:54:38 | <duaneb> | dmwit: well |
| 18:54:39 | <duaneb> | it compiles now |
| 18:54:48 | <duaneb> | dmwit: I loaded 'Lava' instead of 'Lava2000' |
| 18:55:41 | <Baughn> | I.. gah.. |
| 18:56:15 | <Baughn> | @tell conal Your Functor instance and your Monad instance for Event have differing definitions of fmap. One almost works in that filterE thing, the other fails. |
| 18:56:16 | <lambdabot> | Consider it noted. |
| 18:56:23 | <Baughn> | @seen conal |
| 18:56:23 | <lambdabot> | I saw conal leaving #haskell, #ghc and #haskell-in-depth 4h 10m 22s ago, and . |
| 18:58:49 | <skorpan> | @pl \tree -> YiA (jsCompile tree) |
| 18:58:50 | <lambdabot> | YiA . jsCompile |
| 19:00:28 | <Cale> | roconnor: uh, I'm not sure. |
| 19:00:29 | <lambdabot> | Cale: You have 1 new message. '/msg lambdabot @messages' to read it. |
| 19:02:03 | <Cale> | @check \x y -> x < y ==> x^2 < y^2 |
| 19:02:05 | <lambdabot> | No instance for (QuickCheck-1.1.0.0:Test.QuickCheck.Testable |
| 19:02:05 | <lambdabot> | ... |
| 19:02:37 | <Cale> | @check \x y -> x < y ==> x^2 < y^2 |
| 19:02:38 | <lambdabot> | No instance for (QuickCheck-1.1.0.0:Test.QuickCheck.Testable |
| 19:02:39 | <lambdabot> | ... |
| 19:02:41 | <Cale> | hmm |
| 19:03:17 | <Cale> | ah... |
| 19:03:30 | <Cale> | There are 3 versions of quickcheck installed |
| 19:03:55 | <Cale> | But 1.1.0.0 is the global one... |
| 19:05:11 | <Cale> | I don't know how to make it select a different one. |
| 19:06:02 | <Cale> | @check \x y -> x < y ==> x^2 < y^2 |
| 19:06:04 | <lambdabot> | "Falsifiable, after 0 tests:\n-1\n1\n" |
| 19:06:18 | <Cale> | Okay, so removing the user versions of QuickCheck worked. |
| 19:06:52 | <Cale> | It would be nice to have a newer QuickCheck, but it seems to be picking the global rather than the user package, so I don't know what I can do about it. |
| 19:07:14 | <Cale> | (I can't install things globally, or else I would have upgraded ghc by now) |
| 19:07:58 | <dino-> | top |
| 19:08:21 | <Cale> | charm |
| 19:08:54 | <Zao> | Cale: Not enough space in $HOME or /tmp? :) |
| 19:09:43 | <Cale> | Hmm... |
| 19:11:31 | <Cale> | .oO(Do I really want to get into this?) |
| 19:11:38 | <Cale> | Well, I suppose I can try it. |
| 19:12:43 | <Zao> | My $HOME has gigs of self-built software, in order to work around Debian's awesometastic deployment speed. |
| 19:13:30 | <Cale> | I usually install things in /usr/local/ |
| 19:18:59 | <Cale> | Whoops, this is an x86_64 machine apparently... |
| 19:21:57 | <Baughn> | @src liftM |
| 19:21:58 | <lambdabot> | liftM f m1 = do { x1 <- m1; return (f x1) } |
| 19:22:18 | <Baughn> | @. pl undo do { x1 <- m1; return (f x1) } |
| 19:22:19 | <lambdabot> | f `fmap` m1 |
| 19:22:30 | <Baughn> | ..thanks, bot. Really. |
| 19:37:28 | <duaneb> | is there a function for (\(a, b) -> a == b)? |
| 19:37:57 | <Taejo> | duaneb: uncurry (==) |
| 19:38:14 | <Taejo> | :t uncurry |
| 19:38:18 | <lambdabot> | forall a b c. (a -> b -> c) -> (a, b) -> c |
| 19:38:23 | <Taejo> | :t uncurry (==) |
| 19:38:25 | <lambdabot> | forall a. (Eq a) => (a, a) -> Bool |
| 19:38:28 | <duaneb> | right |
| 19:56:17 | <gwern> | @seen nomeata |
| 19:56:17 | <lambdabot> | nomeata is in #xmonad, #haskell and #darcs. I don't know when nomeata last spoke. |
| 19:56:54 | <gwern> | @ask nomeata I find I've been sending darcswatch emails using 'OBSOLETE' or 'REJECTED' instead of '[OBSOLETE]'. could you generalize the keyword? |
| 19:56:55 | <lambdabot> | Consider it noted. |
| 19:57:48 | <nomeata> | gwern: sure, why not |
| 19:57:49 | <lambdabot> | nomeata: You have 1 new message. '/msg lambdabot @messages' to read it. |
| 19:59:45 | <nomeata> | gwern: done |
| 20:00:07 | <gwern> | and maybe rerun on the old emails? :) |
| 20:00:26 | <nomeata> | hmm, that’s not possible, they are not saved |
| 20:00:26 | <gwern> | (I was manually replying to them, but I'd rather not; I'm not sure that even works, as gmail strips attachments) |
| 20:00:46 | <gwern> | how quickly does darcswatch refresh? |
| 20:01:28 | <nomeata> | gwern: upon mails, about immediatelly |
| 20:01:41 | <nomeata> | gwern: otherwise hourly |
| 20:01:51 | <gwern> | (a decent gui/website for darcswatch would actually be good; it feels so fragile and like shots in the dark right now - one has no idea whether an email worked or not) |
| 20:01:54 | <Absolute0> | What do I need to do to use data values in another module? Simply importing the module where the data type is defined doesn't seem to help. |
| 20:02:15 | <Absolute0> | Do I need to export all the values as well? |
| 20:02:34 | <nomeata> | gwern: maybe one should define two mail addresses, one to leech patches off maliing lists, and one where each mail gets a reply about the result |
| 20:02:37 | <nomeata> | patches welcome :-) |
| 20:02:40 | <gwern> | Absolute0: are you sure the original module exports it? |
| 20:03:18 | <gwern> | nomeata: yeah yeah, I know. the obvious solution is to use happstack or one of the other web frameworks, except I don't know any of'em |
| 20:03:53 | <nomeata> | gwern: right, enabling write-web-access would be helpful as well :-) |
| 20:04:54 | <gwern> | be a good summer project though |
| 20:04:57 | <gwern> | how hard could it be? |
| 20:05:53 | <nomeata> | gwern: I have been avoiding that because I once thought of darcswatch as a purly passive thing that just watches projects |
| 20:06:07 | <nomeata> | but it doesn’t fit it’s current usage, I guess |
| 20:06:18 | <nomeata> | it wouldn’t actually be too hard to add some interaction there |
| 20:07:54 | <Cale> | Absolute0: in the export list, if you want to export all the constructors, put (..) after the type name |
| 20:08:16 | <Cale> | Absolute0: Same goes for the import list if you make it explicit. |
| 20:08:40 | <Absolute0> | Cale: is there any syntax to simply export everything? |
| 20:08:44 | <Absolute0> | with no hiding? |
| 20:08:49 | <Cale> | Absolute0: leave the export list out. |
| 20:08:57 | <Absolute0> | thats what I have.. |
| 20:09:26 | <Cale> | Hmm... can I see the module declaration and how you're importing it? |
| 20:09:43 | <Cale> | If you just write |
| 20:09:47 | <Absolute0> | nevermind I forgot the where keyword |
| 20:09:49 | <Absolute0> | :) |
| 20:09:49 | <Cale> | module MyModule where |
| 20:09:52 | <Cale> | ah |
| 20:10:18 | <Cale> | Yeah, that 'where' is a bit funny since GHC only permits one module per file regardless. |
| 20:10:34 | <Heffalump> | but other implementations could behave differently |
| 20:10:38 | <Cale> | But the language spec doesn't say anything about how the source should be broken into files. |
| 20:10:49 | <Heffalump> | and apart from the exception for the indentation rule, it makes things very consistent with other declaration forms |
| 20:11:11 | <hatds> | which means that in theory if want to compile the same project with different compilers you are boned |
| 20:11:17 | <gwern> | nomeata: really, just a button to mark obsolete/rejected would be enough |
| 20:11:27 | <Absolute0> | Do file names and modules file the java convention? |
| 20:11:39 | <Absolute0> | Capital one per file etc.. |
| 20:11:45 | <gwern> | Absolute0: pretty much |
| 20:11:58 | <Zao> | A.B.C usually lives in A/B/C.hs |
| 20:12:02 | <gwern> | I'm not sure java allows Foo.hs, Foo/Bar.hs though |
| 20:12:10 | <gwern> | ACTION not very familiar with java |
| 20:12:13 | <Absolute0> | company link as the module prefix? |
| 20:12:19 | <Heffalump> | Absolute0: no |
| 20:12:30 | <Cale> | That convention is ridiculous ;) |
| 20:12:35 | <Absolute0> | com.sun.somecoolapp |
| 20:12:35 | <Heffalump> | you avoid namespace clashes using the package system if absolutely necessary |
| 20:12:56 | <nomeata> | gwern: hmm. I wonder if that couldn’t be abused too easily (people obsoleting patches they don’t like). with mail, at least the From of the mail is stored... |
| 20:13:10 | <Cale> | The module path should express something about the purpose of the module, not who made it. |
| 20:13:14 | <gwern> | nomeata: if abuse is an issue, authentication can be added later |
| 20:13:25 | <Absolute0> | is the deriving keyword only limited to data definitions? |
| 20:13:34 | <Absolute0> | or can it also be used with type synonyms? |
| 20:13:38 | <gwern> | nomeata: no point in overengineering it - heck, as far as I know I'm the only person using darcswatch |
| 20:13:40 | <pumpkin> | Cale: what if 100 different people made variations on a matrix library |
| 20:13:43 | <Heffalump> | no, it can't be used on type synonyms |
| 20:13:44 | <Cale> | It can be used with newtype and data |
| 20:13:52 | <nomeata> | gwern: true again :-) |
| 20:13:54 | <Heffalump> | pumpkin: then you use packages to pick one |
| 20:13:58 | <Absolute0> | oh |
| 20:14:00 | <Cale> | Not with type synonyms, since it's not valid to put different instances on those anyway. |
| 20:14:09 | <pumpkin> | Heffalump: that's a pain to do unless you're using cabal isn't it? |
| 20:14:21 | <Heffalump> | pumpkin: it can be a bit annoying, yes |
| 20:14:22 | <pumpkin> | but I guess using cabal itself isn't a pain |
| 20:14:38 | <Cale> | > 1 + 1 -- still working? |
| 20:14:43 | <lambdabot> | 2 |
| 20:14:51 | <Cale> | now... |
| 20:14:51 | <hatds> | calling everything Data.Matrix is not a great system imho |
| 20:14:51 | <nomeata> | gwern: (Even I haven’t used it in quite a while. I haven’t submitted patches anywhere for a while, though) |
| 20:15:04 | <pumpkin> | Data.Matrix.HATDS |
| 20:15:07 | <pumpkin> | ;) |
| 20:15:26 | <Heffalump> | in practice people use Data.Matrix.HATDS or whatever, yeah |
| 20:15:27 | <pumpkin> | or just stick your initials onto the end of every module name |
| 20:15:41 | <pumpkin> | not that I like that either |
| 20:15:42 | <Heffalump> | it means that the top levels of the system are used for classification |
| 20:15:53 | <Absolute0> | Can I limit type synonyms to certain ranges? |
| 20:16:03 | <pumpkin> | nope |
| 20:16:08 | <Absolute0> | say type x = [Int] where into is only positive |
| 20:16:26 | <Absolute0> | or [Int] where Int is 0..9 |
| 20:16:28 | <pumpkin> | that would be very nice, but not possible :) |
| 20:17:11 | <gwern> | well, you can have runtime checks |
| 20:17:22 | <gwern> | but static checks put you into dependent types territory |
| 20:17:48 | <Absolute0> | haskell has a slow learning curve :( |
| 20:18:06 | <Absolute0> | 3 tutorials still having trouble.. |
| 20:20:12 | <Raynes> | Absolute0: Have you read Real World Haskell? |
| 20:20:34 | <Absolute0> | http://rafb.net/p/hfFXnR76.html <-- In main ChessPiece cannot be converted to String |
| 20:20:46 | <Absolute0> | Raynes: learn a good haskell is pretty nice. |
| 20:21:17 | <Absolute0> | And since type synononyms cannot derive typeclasses i am stuck |
| 20:21:25 | <gwern> | Absolute0: need to call show |
| 20:21:27 | <Absolute0> | do I explicitly show the tuple? |
| 20:21:30 | <Absolute0> | ah :) |
| 20:21:36 | <gwern> | main = print (Pawn, White, ('a', 6)) |
| 20:21:49 | <gwern> | Char and Int already have show defined |
| 20:21:57 | <wli> | use print instead of putStrLn |
| 20:21:59 | <dino-> | I must be missing something simple about Parsec, but how do you do the regexp equivilent of "(.*)foo" ? |
| 20:21:59 | <gwern> | and you derived show for piece and color; so you're good |
| 20:22:05 | <dino-> | Everything up to "foo" |
| 20:22:49 | <Absolute0> | gwern: print shows the same error |
| 20:23:13 | <mauke> | dino-: everything up to the last "foo" |
| 20:23:18 | <mauke> | hmm, nontrivial |
| 20:23:27 | <gwern> | Absolute0: well, there are other errors in your file |
| 20:23:30 | <gwern> | like the import |
| 20:23:43 | <Cale> | Absolute0: If that's all one file, then you're in trouble :) |
| 20:23:52 | <Absolute0> | gwern: I ran 'cat *hs|paste' you dummy |
| 20:24:11 | <Cale> | Absolute0: but print should be okay |
| 20:24:13 | <gwern> | ACTION feels abashed? |
| 20:24:26 | <Absolute0> | print calls show? |
| 20:24:42 | <gwern> | Absolute0: yup |
| 20:24:51 | <gwern> | print = putStrln . show, iirc |
| 20:24:55 | <gwern> | @src print |
| 20:25:00 | <lambdabot> | print x = putStrLn (show x) |
| 20:25:32 | <gwern> | Absolute0: but yeah, that compiles for me if you replace the do putStrLn with print (and cm out the import) |
| 20:25:50 | <gwern> | (main runs fine too) |
| 20:26:09 | <Absolute0> | http://rafb.net/p/iNo7qR71.html |
| 20:26:10 | <gwern> | oh good, hlint catches the redundant 'do' |
| 20:26:29 | <Absolute0> | http://rafb.net/p/03HSrV84.html |
| 20:26:54 | <gwern> | ACTION has no idea why you put that annotation there |
| 20:27:42 | <Absolute0> | what's the error? |
| 20:27:53 | <Absolute0> | ah |
| 20:27:55 | <Absolute0> | 1 sec |
| 20:28:08 | <Baughn> | ACTION folds, spindles and mutilates Data.Unamb |
| 20:28:31 | <Cale> | Absolute0: the :: ChessPiece annotation applies to the entire expression, including the print |
| 20:28:37 | <Baughn> | (Anyone with detailed knowledge of how unamb works, please speak up) |
| 20:29:24 | <Cale> | Baughn: Well, I'm not sure, but as I recall, it just attempts to evaluate the two expressions concurrently, and the first one to complete wins. |
| 20:29:39 | <Baughn> | Cale: ..yeah, there's a bit of subtlety in that |
| 20:29:47 | <Baughn> | Cale: (The current one doesn't /work/. I'm fixing it.) |
| 20:30:21 | <Cale> | ACTION looks at the source... |
| 20:30:26 | <Cale> | What's wrong with it? |
| 20:30:43 | <Absolute0> | Cale: that's it. :) |
| 20:31:14 | <Baughn> | Cale: ..I'm not really sure, to be honest, but the case of recursive unambs is giving me trouble. |
| 20:31:35 | <Baughn> | Cale: There are further problems (like not using a specialized exception for both being bottom), so I figured I might as well just chuck the code and start over. |
| 20:32:07 | <Baughn> | The current code fails, by way of race conditions. Simple code often works. Makes it hard to write test-cases. |
| 20:33:08 | <mux> | is there an OS independant removeFile function? |
| 20:33:17 | <gwern> | unamb sounds like a giant race condition... how could it fail that way? |
| 20:33:56 | <Cale> | mux: Yes. It's in System.Directory |
| 20:34:17 | <Heffalump> | gwern: the whole point of unamb is to race.. |
| 20:34:18 | <gwern> | actually, why couldn't you just grab a random bit and choose between the 2 functions? wouldn't that be the same thing as unamb? I don't see how a function calling unamb could tell the difference |
| 20:34:20 | <Baughn> | gwern: It likes killing threads. Apparently it's a bit too eager about it. |
| 20:34:25 | <mux> | Cale: thank you |
| 20:34:28 | <gwern> | Heffalump: yeah, that's my point |
| 20:34:33 | <Heffalump> | gwern: one thread might not ever terminate |
| 20:34:37 | <Baughn> | gwern: And no, the point of unamb is that 'unamb undefined 2' evaluates to 2 |
| 20:34:50 | <Baughn> | gwern: Or, unamb a b evaluates to whichever value is not bottom |
| 20:35:06 | <gwern> | oh. sounds like a strange function |
| 20:35:11 | <Baughn> | Oh yes |
| 20:35:28 | <Heffalump> | actually it's a very natural function |
| 20:35:36 | <Baughn> | It escapes breaking referential transparency by the skin of its teeth and careful usage |
| 20:35:40 | <Heffalump> | it just never occurred to anyone before conal came along :-) |
| 20:35:49 | <p_l> | Baughn: is it somehow related to that old crazy macro known as amb? |
| 20:36:05 | <gwern> | p_l: connor's amb? |
| 20:36:11 | <Cale> | Conal's. |
| 20:36:16 | <Cale> | oh |
| 20:36:21 | <Cale> | p_l: no |
| 20:36:27 | <p_l> | oh, ok |
| 20:36:29 | <Heffalump> | (a && b) `unamb` (b && a) is one of the neat uses of it: an and that short-circuits on *both* arguments. |
| 20:37:06 | <Cale> | It doesn't really escape breaking referential transparency. |
| 20:37:21 | <Heffalump> | it breaks it if you violate the pre-condition |
| 20:37:26 | <Cale> | right. |
| 20:37:33 | <Cale> | Which isn't expressed in its type. |
| 20:37:54 | <gwern> | precondition? don't pass it 2 bottoms? |
| 20:38:20 | <Cale> | gwern: The parameters you pass it must be equal if they are not bottom. |
| 20:38:48 | <gwern> | so unamb 2 3 is no good? |
| 20:38:51 | <Cale> | right |
| 20:39:09 | <Cale> | You will get a random result in that case. |
| 20:39:23 | <mauke> | (a `unamb` b) && (b `unamb` a) ? |
| 20:39:24 | <Baughn> | Also, an alligator will leap from your closet and eat you. |
| 20:39:24 | <Cale> | (though practically speaking, I'm pretty sure you'll almost always get 2) |
| 20:39:39 | <Baughn> | a `unamb` b is produces *undefined behaviour* if a /= b |
| 20:39:56 | <Cale> | Not really though. |
| 20:39:58 | <gwern> | what is unamb's type sig? not a -> a -> IO a, I assume from the precondition |
| 20:40:06 | <Baughn> | gwern: a -> a -> a |
| 20:40:17 | <Baughn> | It's implemented in terms of unsafePerformIO and race |
| 20:40:30 | <gwern> | ah. so that's why randomness is bad, since you could run unamb 2 3 twice and get 2 different values |
| 20:40:31 | <dino-> | mm.. manyTill anyChar (try (string "foo")) |
| 20:40:35 | <gwern> | it claims to be pure |
| 20:40:45 | <Philonous> | gwern: Actually passing it two bottoms is intended behaviour. You could do something like True `unamb` (_|_ `unamab` _|_ ) |
| 20:40:59 | <Baughn> | gwern: It is pure, it just requires a precondition the type system can't check |
| 20:41:02 | <BMeph> | dON'T PASS IT TWO *NON*-BOTTOMS, THEN. :) |
| 20:41:05 | <Taejo> | gwern: it's pure subject to its precondition |
| 20:41:13 | <Baughn> | Breaking it is bad, just like using unsafeCoerce is bad |
| 20:41:15 | <dino-> | Is more like non-greedy (.*)foo |
| 20:41:18 | <BMeph> | Whoops, Caps - soory. |
| 20:41:35 | <Taejo> | BMeph: no, don't pass it two values that are incomparable in the definedness relation |
| 20:41:39 | <dons> | roconnor: i see you made the front page of reddit :) |
| 20:41:46 | <Philonous> | BMeph: You can pass it two non-bottoms if they are equal |
| 20:42:04 | <Heffalump> | mauke: that looks wrong. If a finishes first, then it'll evaluate to a no matter what b is. |
| 20:42:09 | <Cale> | (and that's also often needed) |
| 20:42:15 | <Philonous> | BMeph: There is even a use for it: Suppose you have two compuations, one is very expensive, the other one very cheap, but you don't know which one is which |
| 20:42:25 | <Taejo> | Philonous: more than that: (Just _|_ `unamb` Just (Just _|_)) is well-defined, the value is Just (Just _|_) (as I understand) |
| 20:42:32 | <mauke> | Heffalump: oh, right |
| 20:42:39 | <mauke> | whee, alcohol |
| 20:42:59 | <Heffalump> | is unamb the one that goes deeply? |
| 20:43:02 | <Philonous> | Taejo: Yes, that would make sense |
| 20:43:19 | <Cale> | Taejo: no, that doesn't seem to work |
| 20:43:29 | <gwern> | 'haskellers do it with bottoms.' |
| 20:43:31 | <dons> | roconnor: yes, well done. nice article, clear application of theory. practical, unambiguous conclusion. teaches the reader. that's good blogging. |
| 20:43:40 | <BMeph> | Fine, fine - don't pass it two non-bottom values that you *KNOW* cannot be equal. Does that cover it, or should there be more qualifications. |
| 20:43:42 | <Cale> | It only does WHNF |
| 20:43:43 | <BMeph> | ? |
| 20:43:43 | <Heffalump> | dons: what article? |
| 20:44:00 | <Heffalump> | BMeph: don't pass it two non-bottom values that you do not know must be equal |
| 20:44:07 | <Taejo> | my bad, I'm thinking of lub |
| 20:44:22 | <Heffalump> | lub is implemented by a type class, isn't it? |
| 20:44:28 | <Taejo> | unamb requires that it's arguments are _|_ or equal |
| 20:44:34 | <gwern> | Taejo: I'd hope haskellers do it with lub; although people do claim haskell is a S&M language... |
| 20:44:35 | <dons> | roconnor's article on lotteries is on the reddit front page |
| 20:44:46 | <dons> | gwern: though you hear that less these days, |
| 20:44:53 | <dons> | it was more common a few years ago (more static typing these days?) |
| 20:44:55 | <Heffalump> | dons: oh, yeah |
| 20:45:15 | <gwern> | dons: well, with gay marriage becoming more accepted, what's a few kinks like a type system to people these days? |
| 20:45:24 | <dons> | right. |
| 20:45:26 | <BMeph> | Heffalump: If you don't know that they are equal, but you know that they could be equal, use something else, then? :) |
| 20:45:55 | <dons> | after a decade of perl , python, ruby, its refreshing to see type systems coming back. (scala, f#, ) all applying ideas from ICFP :) |
| 20:45:57 | <Baughn> | Heffalump: None of them go deeply, but you could do "x `unamb` (y `using` rnf)" if you'd like |
| 20:47:38 | <tetha> | dons: the interesting thing about haskells type system is that it's powerful enough to be not in the way again |
| 20:47:53 | <Heffalump> | Baughn: that doesn't help with going into the structure of the value |
| 20:48:13 | <Heffalump> | you want (_|_, 3) `lub` (2, _|_) = (2, 3) [which is exactly what lub gives you] |
| 20:48:34 | <hackagebot> | bsd-sysctl 1.0.3 |
| 20:48:42 | <Baughn> | Heffalump: Oh, like that. It would be an interesting exercise.. |
| 20:48:46 | <dons> | tetha: yup |
| 20:48:57 | <Baughn> | Heffalump: You could do it by recursive use of unamb, of course |
| 20:49:08 | <Heffalump> | Baughn: yes, I think that's what lub does, with a typeclass |
| 20:51:48 | <BMeph> | If you did a defn like "b = map sum . inits $ b", would GHC be able to figure out that it's equal to "repeat 0" (er, denotatively, I mean)? |
| 20:52:10 | <Heffalump> | > inits [3,4] |
| 20:52:12 | <lambdabot> | [[],[3],[3,4]] |
| 20:52:34 | <Heffalump> | > fix (map sum . inits) |
| 20:52:40 | <lambdabot> | mueval-core: Prelude.read: no parse |
| 20:52:40 | <lambdabot> | mueval: ExitFailure 1 |
| 20:52:49 | <Heffalump> | ?? |
| 20:53:04 | <BMeph> | From Heffalumps examples, I'm guessing No. :\ |
| 20:53:16 | <Taejo> | > let b = map sum . inits $ b in b |
| 20:53:17 | <pumpkin> | > let b = map sum . inits $ b in b |
| 20:53:21 | <pumpkin> | :P |
| 20:53:22 | <lambdabot> | mueval-core: Prelude.read: no parse |
| 20:53:22 | <lambdabot> | mueval: ExitFailure 1 |
| 20:53:22 | <lambdabot> | mueval-core: Prelude.read: no parse |
| 20:53:22 | <lambdabot> | mueval: ExitFailure 1 |
| 20:53:30 | <Heffalump> | it stack overflows in ghci |
| 20:53:30 | <monochrom> | What? |
| 20:53:41 | <Heffalump> | I think inits isn't lazy enough. |
| 20:53:43 | <Heffalump> | @src inits |
| 20:53:44 | <lambdabot> | inits [] = [[]] |
| 20:53:44 | <lambdabot> | inits (x:xs) = [[]] ++ map (x:) (inits xs) |
| 20:53:49 | <Heffalump> | yep, that's the problem. |
| 20:53:51 | <monochrom> | Ah yes. |
| 20:54:10 | <monochrom> | But "no parse" is really unsatisfactory. |
| 20:54:33 | <Taejo> | > let loop = loop in loop :: String |
| 20:54:39 | <lambdabot> | mueval-core: Prelude.read: no parse |
| 20:54:39 | <lambdabot> | mueval: ExitFailure 1 |
| 20:54:48 | <fracture_> | I have a list, and want to do something for each element that involves all the elements before and after the current one |
| 20:54:52 | <Heffalump> | @let inits' v = []:(case v of { [] -> [] ; (x:xs) -> map (x:) (inits' xs) } ) |
| 20:54:54 | <lambdabot> | Defined. |
| 20:54:55 | <fracture_> | anyone know what I should be looking at to do that? |
| 20:54:59 | <fracture_> | (basically a for loop) |
| 20:55:00 | <Heffalump> | > fix (map sum . inits') |
| 20:55:03 | <lambdabot> | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... |
| 20:55:06 | <monochrom> | Anyway you could predict the result yourself. map sum (inits _|_) = map sum _|_ = _|_ done. |
| 20:55:09 | <pumpkin> | nice :) |
| 20:55:11 | <lament> | fracture_: perhaps a zipper |
| 20:55:12 | <fracture_> | I tried splitAt with a map over a list of ints up to length, but it seems retarded |
| 20:55:17 | <fracture_> | hmm ok |
| 20:55:25 | <Taejo> | fracture: or a foldl |
| 20:55:34 | <Taejo> | it depends on what exactly you're doing |
| 20:55:37 | <fracture_> | I don't think I can do it with fold (unless I just don't know how) |
| 20:55:45 | <Taejo> | even map foo . inits might be ppropriate |
| 20:55:54 | <Taejo> | fracture_: what do you want to do? |
| 20:55:55 | <lament> | but yeah, what are you doing, is it really O(n^2)? |
| 20:56:21 | <monochrom> | "do something for each element that involves all the elements before and after the current one" contains almost no information. |
| 20:56:34 | <Taejo> | oh, I missed the "and after" |
| 20:56:35 | <fracture_> | yeah lemme be more specific |
| 20:56:37 | <lament> | it says O(n^2) |
| 20:56:43 | <Taejo> | so basically, it depends on the whole list |
| 20:56:48 | <lament> | which suggests maybe not use lists at all here |
| 20:56:58 | <fracture_> | so the problem is like... I have a list (it'll be something like [5,2,2,1]), I want to group it [[5],[2,2],[1]] |
| 20:57:07 | <monochrom> | nub |
| 20:57:08 | <fracture_> | then for each group in the group list, I want to mutate the first element of the group |
| 20:57:14 | <fracture_> | concat the whole thing back together and recurse |
| 20:57:16 | <Botje> | mutate? |
| 20:57:16 | <monochrom> | err, group. |
| 20:57:22 | <Taejo> | fracture_: to do the first part, use group |
| 20:57:24 | <fracture_> | well, in an imperative way of thinking |
| 20:57:28 | <fracture_> | yeah got that far |
| 20:57:28 | <lament> | > group [5,2,2,1] |
| 20:57:30 | <lambdabot> | [[5],[2,2],[1]] |
| 20:57:31 | <Botje> | what an odd concept |
| 20:57:46 | <Taejo> | fracture_: then, use map to modify each list |
| 20:57:57 | <fracture_> | that won't work, because I need the whole list for each iteration |
| 20:58:00 | <monochrom> | I don't mind people talking about "mutate". We know how to deconstruct that. |
| 20:58:11 | <Taejo> | fracture_: please explain |
| 20:58:46 | <fracture_> | like, I want to recurse down my function with each group changed at a time |
| 20:58:52 | <monochrom> | Mutate in what way? Concat the whole thing back --- we know how. Recurse in what way? |
| 20:58:57 | <Heffalump> | so should I report a laziness bug against inits? |
| 20:59:00 | <fracture_> | so like, first change the 5 to 2,2,1 |
| 20:59:13 | <fracture_> | then change the 2,2 to 1,1,1,1, but leaving the 5 |
| 20:59:19 | <fracture_> | err actually 2,1,1 |
| 20:59:45 | <monochrom> | When do you stop recursing? Is there a base case? |
| 20:59:48 | <fracture_> | like for sake of making it simpler, imagine I just want to set the first element of each group to 0 in turn |
| 20:59:52 | <Baughn> | ACTION proceeds to deliberately break unamb's invariant. :P |
| 21:00:06 | <Taejo> | fracture_: that's easy... no need to look at the rest of the list |
| 21:00:12 | <fracture_> | so I'd get [[0],[2,2],[1]] first time, then [[5],[0,2],[1,1]] |
| 21:00:17 | <Cale> | > map (\(x:xs) -> 0:xs) . group $ [5,2,2,1] |
| 21:00:19 | <lambdabot> | [[0],[0,2],[0]] |
| 21:00:20 | <fracture_> | monochrom: yes |
| 21:00:22 | <Cale> | huh? |
| 21:00:31 | <fracture_> | yeah but I want the whole list each time |
| 21:00:42 | <Cale> | "each time"? |
| 21:00:52 | <Cale> | ah |
| 21:00:59 | <Cale> | Maybe I know what you mean... |
| 21:01:01 | <fracture_> | ok let's say I want to call the function "foo" (forget about recursion) N times |
| 21:01:03 | <fracture_> | the number of groups |
| 21:01:11 | <fracture_> | and each time should have a different mutated group in the list it gets |
| 21:01:13 | <fracture_> | as an argument |
| 21:01:15 | <Taejo> | fracture_: why not give an example of a call to your function, and the desired result |
| 21:01:28 | <fracture_> | because it's a long story ;) |
| 21:01:59 | <fracture_> | I guess I had something kinda like this yesterday (if anyone remembers that 'mappish' function)... seems like there should be an easier way to do it though |
| 21:02:02 | <dmwit> | A zipper is exactly the right data structure for this, in my opinion. |
| 21:02:02 | <Taejo> | fracture_: I must say I don't see how it can be harder to give an example than a specification |
| 21:02:14 | <monochrom> | By training and self-selection, programmers can express "how" but not "what", and nevermind "why". It's pretty sad. |
| 21:02:17 | <dmwit> | It seems pretty clear what he wants to do. |
| 21:02:29 | <fracture_> | Taejo: this question is more about how to do something generally than a particular function |
| 21:02:40 | <fracture_> | if I just wanted the function, I'd stick with splitAt and a psuedo for loop |
| 21:02:53 | <fracture_> | ok I'll look into zip |
| 21:02:58 | <dmwit> | data Zipper a = Zipper { before :: [a], current :: a, after :: [a] } -- "before" is stored in reverse order |
| 21:03:10 | <fracture_> | is that from the library? |
| 21:03:11 | <dmwit> | No, not zip; a zipper. (They're really different. =)) |
| 21:03:13 | <fracture_> | ahh |
| 21:03:16 | <fracture_> | this sounds more like it |
| 21:03:35 | <Taejo> | how do you get lambdabot to remember quotes? |
| 21:03:35 | <dmwit> | next :: Zipper -> Maybe Zipper |
| 21:03:40 | <monadic_kid> | there was a good blog about zippers |
| 21:03:53 | <fracture_> | dmwit: what lib is zipper in? |
| 21:04:04 | <dmwit> | next (Zipper bs c []) = Nothing; next (Zipper bs c (a:as)) = Just (Zipper (c:bs) a as) |
| 21:04:11 | <dmwit> | fracture_: I'm making it up as I go. |
| 21:04:14 | <fracture_> | oh |
| 21:04:18 | <monadic_kid> | http://blog.lab49.com/archives/2984 |
| 21:04:37 | <dmwit> | fracture_: I think there is some stuff for generic one-hole contexts, but it's a bit tricky to understand. |
| 21:04:52 | <dmwit> | At least, I never understood it, though I never spent very long trying to. ^_^ |
| 21:05:18 | <fracture_> | hmm |
| 21:05:33 | <fracture_> | seems potentially overkill for something this simple... let me look around though |
| 21:05:34 | <monadic_kid> | purely-functional incremental mutation (Zippers): http://blog.lab49.com/archives/2984 |
| 21:05:51 | <Taejo> | @remember monochrom By training and self-selection, programmers can express "how" but not "what", and nevermind "why". |
| 21:05:53 | <lambdabot> | Done. |
| 21:08:21 | <Cale> | > map (\(xss,(y:ys):yss) -> xss ++ (0:ys):yss) . liftM2 zip inits (init . tails) . group $ [5,2,2,1] |
| 21:08:23 | <lambdabot> | [[[0],[2,2],[1]],[[5],[0,2],[1]],[[5],[2,2],[0]]] |
| 21:08:31 | <Absolute0> | Is it possible to get a list of all the values of a type? |
| 21:08:42 | <Cale> | Absolute0: Not in general. |
| 21:08:56 | <Absolute0> | ie: data x = a | b | c ; listify x -> [a,b,c] |
| 21:09:16 | <fracture_> | Cale: that looks nicer; a tad hard to understand for me thus far though |
| 21:09:18 | <fracture_> | lemme think about it |
| 21:09:19 | <Cale> | Types also cannot be parameters to functions. |
| 21:09:27 | <jaredj> | Text.Parsec.Char> :t anyChar |
| 21:09:32 | <BMeph> | ACTION doesn't understand how someone can call something "simple" that they can't explain |
| 21:09:33 | <Cale> | Well, perhaps I can make it easier to understand. |
| 21:09:34 | <jaredj> | aw |
| 21:09:42 | <jaredj> | > :t anyChar |
| 21:09:43 | <lambdabot> | <no location info>: parse error on input `:' |
| 21:10:00 | <Absolute0> | Cale: so I have to tediously type all the values on my own to achieve that? |
| 21:10:07 | <Absolute0> | seems very unhaskellish :) |
| 21:10:31 | <Philonous> | Absolute0: derive Enum, than you can do [FirstCOnstructor .. LastCOnstructor] |
| 21:10:39 | <Cale> | Absolute0: What should listify (IO ()) return? |
| 21:10:41 | <Absolute0> | aha |
| 21:10:43 | <Absolute0> | :) |
| 21:10:45 | <mux> | is it possible to set the -N RTS flags at runtime these days? |
| 21:10:47 | <skorpan> | is there any general alias for "return ()"? |
| 21:10:57 | <Absolute0> | thanks Philonous :) |
| 21:11:11 | <Cale> | skorpan: alias? |
| 21:11:19 | <Zao> | pure () ? :) |
| 21:11:22 | <monadic_kid> | pure () ? not really an alias |
| 21:11:23 | <Cale> | skorpan: That's pretty simple as it is :) |
| 21:11:23 | <Philonous> | mux: I asked that yesterday, and the answer was: unfortunately no, you need to write a wrapper or use hooks from within C |
| 21:11:33 | <BMeph> | Can't do that with Integer, though - which may not be a bad thing. ;) |
| 21:11:34 | <dmwit> | :t Text.Parsec.Char.anyChar -- jaredj, your syntax was wrong =) |
| 21:11:36 | <lambdabot> | Couldn't find qualified module. |
| 21:11:43 | <mux> | Philonous: we need to fix that at some point |
| 21:11:58 | <skorpan> | Cale: yeah, but i use "trace" in monadic functions a lot, so i have to do e.g. 'trace "hello" $ return ()' |
| 21:12:13 | <Philonous> | Absolute0: But afaik that only works iff all your constructors are Nullary |
| 21:12:14 | <Cale> | skorpan: which monad? |
| 21:12:25 | <skorpan> | Cale: in this case BufferM in Yi :P |
| 21:12:32 | <Cale> | Isn't that a MonadIO? |
| 21:12:41 | <skorpan> | probably, let me check |
| 21:12:50 | <skorpan> | no, it's not :/ |
| 21:12:54 | <Cale> | hmm, okay |
| 21:13:05 | <skorpan> | what were you thinking? |
| 21:13:11 | <Absolute0> | How can I list all the possible operators on a typeclass? |
| 21:13:14 | <Cale> | I was thinking liftIO (print "hello") |
| 21:13:16 | <Absolute0> | in ghci |
| 21:13:18 | <dmwit> | skorpan: You could... you could write "done = return ()". It wouldn't take that long. |
| 21:13:31 | <Cale> | Absolute0: You... don't. |
| 21:13:35 | <dmwit> | trace "hello" done |
| 21:13:39 | <skorpan> | Cale: i need to use 'trace' though, because otherwise i'll mess the terminal up... yi catches traces and puts them in a file |
| 21:13:48 | <Cale> | Absolute0: You look at the sourcecode for the typeclass :) |
| 21:13:50 | <dmwit> | Or even traceMonad x = trace x (return ()) |
| 21:13:53 | <skorpan> | dmwit: yeah, but i was just asking |
| 21:14:03 | <Absolute0> | Cale nothing like the python dir(Enum) in haskell? |
| 21:14:07 | <Cale> | skorpan: Oh, weird. |
| 21:14:09 | <dmwit> | :i Enum |
| 21:14:19 | <mux> | skorpan: you could maybe add a WriterT to your monad stack and use "tell" instead of "trace" |
| 21:14:23 | <Cale> | oh, I suppose that does give a definition |
| 21:14:55 | <skorpan> | Cale: it's pretty cool though, it catches error and undefined as well |
| 21:14:55 | <dmwit> | (@Absolute0) |
| 21:14:55 | <Philonous> | Absolute0: If you want to make your type anumerable, just add deriving (Enum) after the type definition, ghc will then figure it out for you |
| 21:15:03 | <Cale> | :info works |
| 21:15:18 | <Absolute0> | Philonous: i got that working already :) Just curious what else Enum offers. |
| 21:15:28 | <Cale> | I don't really use that though. It's usually better just to open up the documentation. :) |
| 21:15:50 | <Absolute0> | ad hoc documentation ftw! :) |
| 21:15:57 | <Cale> | Well, it's haddocked. |
| 21:16:10 | <lament> | hadhoc |
| 21:16:20 | <Cale> | So at least it'll be accurate, if not very elaborate. |
| 21:16:30 | <monochrom> | ghci should just write the right program for you and save all the handshaking overhead. |
| 21:17:00 | <BMeph> | ACTION pities the fool who tries to "listify" Integer... >;) |
| 21:17:28 | <Cale> | skorpan: Anyhow, you could define traceM msg = trace msg (return ()) |
| 21:17:29 | <dmwit> | > let interleave (x:xs) ys = x : interleave ys xs in interleave [0..] [-1, -2..] |
| 21:17:30 | <lambdabot> | [0,-1,1,-2,2,-3,3,-4,4,-5,5,-6,6,-7,7,-8,8,-9,9,-10,10,-11,11,-12,12,-13,13... |
| 21:17:32 | <Philonous> | > [1.. ] BMeph: you mean like that? ^^ |
| 21:17:34 | <lambdabot> | <no location info>: parse error on input `^^' |
| 21:17:39 | <dmwit> | Philonous: I win! |
| 21:17:57 | <skorpan> | Cale: yup, thanks |
| 21:18:10 | <BMeph> | Philonous: Right - more like what dmwit did. :) |
| 21:18:43 | <Cale> | > let posRationals = 1 : (posRationals >>= \x -> [1+x, 1/(1+x)]) in posRationals |
| 21:18:45 | <lambdabot> | [1.0,2.0,0.5,3.0,0.3333333333333333,1.5,0.6666666666666666,4.0,0.25,1.33333... |
| 21:18:51 | <Cale> | > let posRationals = 1 : (posRationals >>= \x -> [1+x, 1/(1+x)]) in posRationals :: [Rational] |
| 21:18:52 | <lambdabot> | [1 % 1,2 % 1,1 % 2,3 % 1,1 % 3,3 % 2,2 % 3,4 % 1,1 % 4,4 % 3,3 % 4,5 % 2,2 ... |
| 21:18:54 | <Philonous> | In my list, the negative numbers come after all the positive ones. So it is complete, too :) |
| 21:19:17 | <Cale> | > let posRationals = 1 : (posRationals >>= \x -> [1+x, 1/(1+x)]) :: [Rational] in 0 : (posRationals >>= \x -> [x,-x]) |
| 21:19:19 | <lambdabot> | [0 % 1,1 % 1,(-1) % 1,2 % 1,(-2) % 1,1 % 2,(-1) % 2,3 % 1,(-3) % 1,1 % 3,(-... |
| 21:19:48 | <Cale> | @let posRationals = 1 : (posRationals >>= \x -> [1+x, 1/(1+x)]) :: [Rational] |
| 21:19:50 | <lambdabot> | Defined. |
| 21:20:32 | <Cale> | @let pyth r = (x,y,z) where m = numerator r; n = denominator r; [x,y,z] = sort [2*m*n, m^2 - n^2, m^2 + n^2] |
| 21:20:34 | <lambdabot> | Defined. |
| 21:20:48 | <BMeph> | Philonous: But in your specification, you never mention negatives, so it's only "complete" if we believe hard enough... ;) |
| 21:20:49 | <Cale> | > map (pyth . (+1)) posRationals |
| 21:20:52 | <lambdabot> | [(3,4,5),(6,8,10),(5,12,13),(8,15,17),(7,24,25),(20,21,29),(16,30,34),(10,2... |
| 21:21:25 | <monochrom> | listify n = replicate n () |
| 21:22:20 | <Cale> | Philonous: Every element of an infinite list has a finite index at which it occurs. Which index in your list is -1 at? :) |
| 21:23:15 | <Deewiant> | Cale: maxBound + 1 |
| 21:23:17 | <BMeph> | Cale: s/an/a countably/ surely? ;) |
| 21:23:29 | <Cale> | BMeph: "list" means "countably" |
| 21:23:32 | <Philonous> | Cale: How do you know that? You have just never seen one with an infinite index. |
| 21:23:54 | <wli> | ACTION would just interleave the positives and negatives. |
| 21:23:57 | <SamB> | Philonous: you can't make such a list out of cons cells |
| 21:24:02 | <dmwit> | Deewiant: No instance for "Bounded Integer"; Probably fix: declare an instance for Bounded Integer |
| 21:24:04 | <monochrom> | We define list to be contably infinite. |
| 21:24:09 | <BMeph> | Cale: That I did not know - thanks! :) |
| 21:24:12 | <Deewiant> | dmwit: You're clearly using the wrong type |
| 21:24:31 | <Deewiant> | There seems to be some garbage after "Int"; a typo? |
| 21:24:43 | <Cale> | Lists are essentially functions from (initial segments of) the natural numbers to some set/type. |
| 21:24:53 | <dmwit> | Deewiant: No typo, defaulting chooses Integer. ;-) |
| 21:25:22 | <Deewiant> | dmwit: Your program is buggy, as -Wall will tell you |
| 21:25:57 | <dmwit> | Anyway, (maxBound + 1 :: Int) isn't a valid index in any list. So ha! |
| 21:26:00 | <dmwit> | I win again! |
| 21:26:10 | <BMeph> | ACTION wonders if Deewiant compiles with "-Wall -e"... |
| 21:26:17 | <Cale> | > maxBound :: Integer |
| 21:26:19 | <lambdabot> | No instance for (GHC.Enum.Bounded GHC.Integer.Internals.Integer) |
| 21:26:19 | <lambdabot> | arising... |
| 21:26:28 | <Deewiant> | BMeph: I don't use -e :-P |
| 21:26:34 | <Philonous> | SamB: That's true. But you can build a list as a graph where the vertexes are the elements and the edges point from any vertex to all it's predecessors. Than you can concatenate two infinite lists. |
| 21:26:49 | <Cale> | @let triples = map (pyth . (+1)) posRationals |
| 21:26:51 | <lambdabot> | Defined. |
| 21:27:03 | <Deewiant> | dmwit: That was just pseudocode, of course I meant toInteger (maxBound :: Int) + 1 ;-) |
| 21:27:18 | <dmwit> | hee hee |
| 21:27:23 | <dmwit> | Pedantry is Fun! |
| 21:27:26 | <Cale> | I love that definition of the Pythagorean triples :) |
| 21:27:29 | <Deewiant> | PiF! |
| 21:27:32 | <SamB> | Philonous: that sounds a bit inside-out ... |
| 21:27:43 | <wli> | ACTION suspects there's a faster way to get Pythagorean triples. |
| 21:27:46 | <dmwit> | :t toInteger |
| 21:27:47 | <lambdabot> | forall a. (Integral a) => a -> Integer |
| 21:27:49 | <dmwit> | :t fromIntegral |
| 21:27:50 | <lambdabot> | forall a b. (Integral a, Num b) => a -> b |
| 21:27:57 | <dmwit> | Haskell is weird. |
| 21:28:12 | <Cale> | wli: well, it is pretty fast already |
| 21:28:34 | <Philonous> | SamB: At least that's how you you concatenate infinite traces |
| 21:28:39 | <mux> | wli: this page lists many methods and stuff about pythagorean triples: http://www.mcs.surrey.ac.uk/Personal/R.Knott/Pythag/pythag.html |
| 21:28:40 | <wli> | I think there's some parametrization or some such. |
| 21:28:46 | <mux> | m,n generators |
| 21:29:07 | <Cale> | wli: That's what this is doing, is it not? |
| 21:30:56 | <Cale> | It generates all the rationals greater than 1 and uses them to parametrise an arc on the unit circle via stereographic projection, and then kills off the common denominator to get an integer triple. |
| 21:31:46 | <mgee> | Hey, just a quick question. How can I add elements of a list to another using the ":" operator and map? I tried: map (flip :myList) mySecondList ... |
| 21:31:58 | <wli> | Apparently so. I guess it works. |
| 21:32:16 | <Cale> | mgee: flip :myList is the same as flip : myList |
| 21:32:17 | <dmwit> | :t (++) |
| 21:32:18 | <lambdabot> | forall a. [a] -> [a] -> [a] |
| 21:32:29 | <skorpan> | > let xs = [1, 2, 3] in map (\x -> x:xs) [4, 5, 6] |
| 21:32:29 | <dmwit> | :t \myList -> flip (:myList) |
| 21:32:30 | <lambdabot> | [[4,1,2,3],[5,1,2,3],[6,1,2,3]] |
| 21:32:30 | <lambdabot> | Couldn't match expected type `b -> c' against inferred type `[a]' |
| 21:32:30 | <lambdabot> | In the first argument of `flip', namely `(: myList)' |
| 21:32:30 | <lambdabot> | In the expression: flip (: myList) |
| 21:32:35 | <skorpan> | cool :) |
| 21:32:42 | <skorpan> | not exactly what you wanted i guess |
| 21:33:11 | <Cale> | mgee: Your constraint that we use : and map is a bit strange... |
| 21:33:12 | <dmwit> | But yeah, you probably just want (++). |
| 21:34:56 | <mgee> | skorpan: thx, that should work :) |
| 21:35:12 | <Cale> | Oh, is that what you actually wanted? |
| 21:35:27 | <Phyx-> | Hi, anyone else also have the problem that in ghci 6.10.3 you can't paste anymore? it only grabs the first character and not the rest, on windows |
| 21:35:39 | <Cale> | paste? |
| 21:35:54 | <mgee> | Cale: mhh. now when i look on the lambdabot post, i think its not... :-/ |
| 21:35:55 | <Cale> | I had no idea that ghci had anything to do with copying/pasting. |
| 21:36:03 | <Cale> | > [1,2,3] ++ [4,5,6] |
| 21:36:05 | <lambdabot> | [1,2,3,4,5,6] |
| 21:36:12 | <Cale> | mgee: Is that what you want? |
| 21:36:23 | <Cale> | mgee: map is for doing something to each element of a list |
| 21:36:30 | <mgee> | really? |
| 21:36:42 | <mgee> | I thought ++ runs always the length of the longest list |
| 21:37:01 | <duaneb> | Igloo: I'm the owner of the powerpc jump bug |
| 21:37:04 | <Cale> | (++) always takes time proportional to the length of its *left* parameter. |
| 21:37:11 | <duaneb> | how hard might something like this be |
| 21:37:13 | <Cale> | Er, well, that's not quite true. |
| 21:37:20 | <mux> | laziness often helps though |
| 21:37:25 | <Cale> | That assumes that you evaluate the whole thing, yeah. |
| 21:37:38 | <mux> | so it somehow get "fused" with the code that consumes the list |
| 21:37:43 | <Cale> | It takes time proportional to the min of the number of elements you look at and the length of the left parameter. |
| 21:38:15 | <mgee> | Cale: I have always a very short list and a very long list... |
| 21:38:29 | <Cale> | The short list should go on the left then, if you care about performance. |
| 21:38:37 | <Cale> | short ++ long |
| 21:38:39 | <pejo> | mux, I think people will think the intermediate stuff disappears if you say fuse. |
| 21:38:57 | <mux> | right, this isn't the correct term but I had no idea how else to put it |
| 21:38:59 | <mgee> | Cale: it is on the left side, but the code is very slow... |
| 21:39:17 | <Cale> | mgee: There's another approach you can take then |
| 21:39:28 | <mgee> | Cale: yep. will look into it. thanks anyway :) |
| 21:39:38 | <Cale> | mgee: Instead of working with lists, you can work with functions which add elements to the beginning of another list |
| 21:39:41 | <Phyx-> | Cale: maybe or maybe not, but it's only not working in ghci 6.10.3 |
| 21:39:50 | <Phyx-> | works fine in anything else and every other version of ghci |
| 21:39:51 | <Cale> | mgee: Then, composition of those functions becomes concatenation |
| 21:39:56 | <Phyx-> | so, i'd say.. it's ghci |
| 21:40:03 | <mgee> | Cale: I will try that approach now :) |
| 21:40:05 | <Cale> | mgee: and to get a proper list at the end, you can apply the function to the empty list |
| 21:40:11 | <dmwit> | mgee: If you have a list of lists, you might just want concat. |
| 21:40:18 | <Cale> | composition is a constant-time operation |
| 21:40:22 | <dmwit> | > concat [[1, 3, 5], [2, 4, 6], [3, 7]] |
| 21:40:23 | <lambdabot> | [1,3,5,2,4,6,3,7] |
| 21:40:45 | <Cale> | Phyx-: Doesn't the terminal handle copy/paste? |
| 21:41:22 | <Cale> | Phyx-: I don't see how it could even be ghci's responsibility... it just outputs characters and reads input from the keyboard. |
| 21:41:34 | <Phyx-> | Cale: the terminal on itself works fine, and the same terminal + ghci 6.10.1 work aswell, wouldn't that stand to reason that it's something between the interaction of the terminal and ghci? |
| 21:41:36 | <pejo> | Cale, haskeline handles the terminal |
| 21:41:52 | <mux> | god bless haskeline |
| 21:41:54 | <Cale> | pejo: I suppose it does output lots of control characters. |
| 21:42:16 | <Cale> | Phyx-: The library used to handle line-editing has changed. |
| 21:42:36 | <Cale> | Phyx-: as in when you press the arrow keys to get previous inputs etc. |
| 21:43:09 | <Cale> | pejo: But haskeline doesn't even know the mouse exists... |
| 21:43:32 | <Cale> | (or have any concept of what the current selection is) |
| 21:43:43 | <Phyx-> | Cale: that works fine, what doesn't, is when i copy for instance some line from somewhere, and paste it to ghci, only the first letter is pasted, on another terminal window, with ghci not running it paste s full line |
| 21:43:44 | <Cale> | at least, I wouldn't think that it does... |
| 21:44:15 | <Cale> | Phyx-: Very strange. I'm not on windows, so I'm not sure. |
| 21:44:26 | <Cale> | I can't try it myself. |
| 21:45:13 | <Phyx-> | i can record it, one sec |
| 21:45:30 | <Cale> | Well, I believe you :) |
| 21:46:08 | <Cale> | I just can't imagine why it would happen. Windows has always had a strange terminal emulator though. |
| 21:47:35 | <Phyx-> | it's pretty annoying at times, especially when i want to copy a line from my source and test in ghci |
| 21:47:38 | <fracture_> | Cale: think I got what I wanted (starting from what I grokked in yours) |
| 21:47:45 | <Baughn> | Assume I've got "unamb x = unsafePerformIO (foo x)" |
| 21:47:48 | <fracture_> | mapping over a zip (inits foo) (tails foo) is the way to go |
| 21:48:02 | <fracture_> | (actually I skip the last one of that) |
| 21:48:21 | <Baughn> | Now, if something throws an exception to the thread running this code, the exception of course kills the thread |
| 21:48:24 | <fracture_> | map (\(x,y) -> {whatever}) $ init (zip (inits foo) (tails foo)) |
| 21:48:44 | <Baughn> | But what happens if I (for let bar = unamb x) later re-evaluate bar? |
| 21:48:56 | <Phyx-> | Cale: but mostly, i wanted to know if i was the only one with the problem, but i suppose most people here don't use windows |
| 21:49:05 | <Baughn> | Or, rather - I happen to know it doesn't work, already. So how do I make it work, re-invoking the IO code? |
| 21:49:22 | <Heffalump> | Baughn: huh? Do you mean unamb x y = unsafePerformIO ... ? |
| 21:49:38 | <Baughn> | Heffalump: ..well, yes. I was simplifying a bit |
| 21:51:02 | <Phyx-> | oh well,i'll test on my other pcs, if it's the same i'll file a bug report |
| 21:51:24 | <eivuokko> | Phyx, http://trac.haskell.org/haskeline/ticket/80 |
| 21:51:49 | <eivuokko> | Phyx, You are not alone, that is. |
| 21:52:48 | <Phyx-> | eivuokko: ah ok, and it's known, guess i'll wait it out :( can't go back to 10.1 since they fixed something in 10.3 i needed |
| 21:52:57 | <eivuokko> | Or .2? |
| 21:53:36 | <Phyx-> | oh, the bug is only .3? i skipped .2 so i don't know |
| 21:53:59 | <eivuokko> | Yeah, should be. |
| 21:54:08 | <eivuokko> | And it does work for me in .2 and Vista. |
| 21:54:18 | <Phyx-> | ok, cool, i'll go back then to .2 |
| 21:54:54 | <Phyx-> | eivuokko: thanks :) |
| 21:56:06 | <Phyx-> | brb |
| 21:57:34 | <Heffalump> | Baughn: ok, so I don't follow your next point. What does for do? |
| 21:57:48 | <Heffalump> | oh, it's english, never mind |
| 21:58:00 | <Heffalump> | so why does it matter if you do later re-evaluate bar? |
| 21:58:21 | <Heffalump> | foo in the definition of unamb is just 'amb', which is referentially transparent as long as the unamb precond is satisfied |
| 21:58:29 | <Heffalump> | and doesn't do any weird IO observably |
| 21:58:34 | <Baughn> | Heffalump: The problem is this: |
| 21:58:49 | <Baughn> | Heffalump: If I say "let a = unamb expensiveOperation undefined" |
| 21:58:58 | <Baughn> | Heffalump: And then I say "let b = unamb a 42" |
| 21:59:08 | <mgee> | Cale: I solved it |
| 21:59:26 | <Baughn> | Heffalump: If I use b, the thread evaluation a will necessarily be killed, to avoid doing the expensive operation. |
| 21:59:27 | <Heffalump> | you're worried about expensiveOperation being repeated? |
| 21:59:30 | <Baughn> | No |
| 21:59:37 | <Baughn> | I'm worried about it /not/ being repeated. |
| 21:59:51 | <Baughn> | See, if I then later demand the value of a, I get a threadKilled exception. |
| 22:00:15 | <mgee> | Cale: The solution is somewhat plain... http://rafb.net/p/v8bAA088.html |
| 22:00:15 | <Heffalump> | Baughn: right, yeah |
| 22:00:26 | <Baughn> | Heffalump: So I need to work around that, somehow. |
| 22:00:28 | <Heffalump> | nasty, ask conal about it? |
| 22:00:34 | <Baughn> | I will, once he's around |
| 22:00:48 | <Heffalump> | conal, your clever ideas are broken, please fix them, kthxbye ;-) |
| 22:01:01 | <EvilTerran> | ?src (++) |
| 22:01:01 | <lambdabot> | [] ++ ys = ys |
| 22:01:02 | <lambdabot> | (x:xs) ++ ys = x : (xs ++ ys) |
| 22:01:02 | <lambdabot> | -- OR |
| 22:01:02 | <lambdabot> | xs ++ ys = foldr (:) ys xs |
| 22:01:04 | <Baughn> | Heffalump: Well, I've actually got a solution |
| 22:01:09 | <Baughn> | Heffalump: The problem is, it's broken. ;) |
| 22:01:10 | <EvilTerran> | mgee, that looks awfully familiar ^ |
| 22:01:43 | <Baughn> | Heffalump: Broken by throwTo not delivering exceptions immediately if a thread blocks, and then unblocks and blocks again in quick succession |
| 22:01:46 | <mgee> | EvilTerran: I am sure haskell already has such function... please name it ;) |
| 22:02:02 | <Baughn> | Heffalump: (Which is noted in the documentation as being undesirable, too. Heh. Now I know why.) |
| 22:02:05 | <Heffalump> | Baughn: the real point is that asynchronous exceptions shouldn't affect a thunk |
| 22:02:10 | <EvilTerran> | actually, that'd be more like \xs ys -> reverse xs ++ ys, but yours would indeed be more efficient than that. never mind, carry on. |
| 22:02:19 | <Heffalump> | it feels more like a GHC bug to me than anything else |
| 22:02:39 | <fracture_> | how would you sort a list in descending order? |
| 22:02:48 | <Baughn> | Heffalump: You may be right about that. I'll try reporting it. |
| 22:02:49 | <Heffalump> | fracture_: sortBy (flip compare) |
| 22:02:53 | <fracture_> | thanks |
| 22:02:57 | <mgee> | EvilTerran: I tried ++ before and it was too slow |
| 22:03:00 | <EvilTerran> | > sortBy (flip compare) "abracadabra" |
| 22:03:01 | <lambdabot> | "rrdcbbaaaaa" |
| 22:03:52 | <Baughn> | Heffalump: I've got this long .hs file of increasingly low-level main functions... |
| 22:04:12 | <Baughn> | Heffalump: Hum. I started off by wanting to play a game. Now I'm filing GHC bug reports. |
| 22:04:39 | <Baughn> | "Play game -> Write map generator UI -> Learn reactive -> Debug reactive -> Debug unamb -> Debug GHC" |
| 22:04:52 | <Heffalump> | :-) |
| 22:04:57 | <eivuokko> | <