<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 _2_5 26 27  
28 29 30 31
00:00 crave joined
00:03 malaclyps joined
00:11 louispan joined
00:13 kadoban joined
00:20 amuck_ joined
00:24 juanpaucar joined
00:26 chlong joined
00:26 juanpaucar joined
00:33 juanpaucar joined
00:38 juanpaucar joined
00:40 colt44 joined
00:42 <lpaste> colt44 pasted “esqueleto” at http://lpaste.net/355660
00:42 <colt44> guys, is it possible to write that query usin esqueleto's dsl?
00:43 juanpaucar joined
00:45 takle joined
00:48 juanpaucar joined
00:52 juanpauc_ joined
00:53 takle joined
00:57 juanpaucar joined
00:58 vaibhavsagar joined
01:01 bumpkin joined
01:01 juanpaucar joined
01:03 <Squarism> anyone used https://hackage.haskell.org/package/lrucaching-0.3.1 ? I wonder how i can obtain all keys of the cache?
01:04 <Squarism> all type classes only seem to expose values
01:06 juanpaucar joined
01:07 <geekosaur> https://hackage.haskell.org/package/lrucaching-0.3.1/docs/Data-LruCache-Internal.html you must access the internal HashPSQ and use that type's access mechanisms
01:08 <geekosaur> https://jaspervdj.be/posts/2015-02-24-lru-cache.html linked in the README is also relevant
01:08 <Squarism> ok.. so not really meant to be used that way then i guess
01:08 <geekosaur> no, I'd expect not
01:09 <geekosaur> if you want to access via key or via priority/age, you want the PSQ directly
01:09 <geekosaur> because that's what a PSQ is
01:09 <geekosaur> so skip this package and go straight to the PSQ it wraps :)
01:09 <geekosaur> (psqueues package)
01:09 <Squarism> ah ok
01:10 <Squarism> what does it mean if a field has "!" infront of type like : "lruCapacity :: !Int"
01:10 <geekosaur> it means the field is strict (will be forced to WHNF)
01:11 juanpauc_ joined
01:11 <Squarism> ah ok
01:11 saussure joined
01:15 juanpaucar joined
01:18 <jle`> Squarism: it means that if you ever resolve the constructor, you also resolve the field (to whnf)
01:18 <jle`> @let data NoStrict = NS { ss :: !Int }
01:18 <lambdabot> Defined.
01:19 <jle`> um i definitely messed that up
01:20 dni- joined
01:20 juanpaucar joined
01:21 <geekosaur> that definition looks slightly oxymoronic to me >.>
01:22 dobson` joined
01:22 <Squarism> laziness turned off
01:22 _rgn joined
01:22 <geekosaur> only partially though
01:23 <geekosaur> > take 1 . ss $ NS [1,undefined]
01:23 <lambdabot> error:
01:23 <lambdabot> • Couldn't match type ‘Int’ with ‘[a]’
01:23 <lambdabot> Expected type: NoStrict -> [a]
01:23 <geekosaur> whoops
01:23 <geekosaur> well, right, I need a different type for that
01:23 bumpkin- joined
01:24 <geekosaur> anyway if you make a ![Int] field, the only thing forced is [] for an empty list or the first 'cons' for a non-empty list
01:24 <geekosaur> (1:undefined) can be a value of such a field
01:24 <geekosaur> but undefined itself cannot
01:24 juanpaucar joined
01:27 jship joined
01:27 <jle`> yes sorry i did mess up the deifnition, heh
01:27 <jle`> @undefine
01:27 <lambdabot> Undefined.
01:27 <jle`> @let data YesStrict = YS { ys :: !Int }; data NoStrict = NS { ns :: Int }
01:28 <lambdabot> Defined.
01:28 <jle`> > case YS undefined of YS _ -> True
01:28 <lambdabot> *Exception: Prelude.undefined
01:28 <jle`> > case NS undefined of YS _ -> True
01:28 <lambdabot> error:
01:28 <lambdabot> • Couldn't match expected type ‘NoStrict’
01:28 <lambdabot> with actual type ‘YesStrict’
01:28 <jle`> > case NS undefined of NS _ -> True
01:28 <lambdabot> True
01:28 mjora7 joined
01:28 <jle`> normally, if you want to resolve that something was made with a given constructor, you don't have to look at the fields
01:28 qwertydvorak joined
01:29 <jle`> but with !, it's like a runtime hook that says evaluate the field when you evaluate the constructor
01:29 <jle`> > case NS (sum [1..]) of NS _ -> True
01:29 <lambdabot> True
01:29 <jle`> > case YS (sum [1..]) of YS _ -> True
01:29 juanpauc_ joined
01:29 eacameron joined
01:29 <lambdabot> mueval-core: Time limit exceeded
01:29 <lambdabot> mueval: ExitFailure 1
01:29 malaclyps joined
01:30 <jle`> my examples were also kind of silly because NoStrict and YesStrict only had one constructor, so it might be seen as "obvious" that they were made using NS/YS
01:30 <jle`> but just assume that they had other constructors, heh
01:30 <Squarism> thanks for trying! =D
01:31 <jle`> (you can aslo make a YesStrict w/o the YS constructor by using an infinite loop or something, so in that case, resolving the constructor is impossible even though there's only one, but that's a different thing)
01:32 ianandrich joined
01:34 juanpaucar joined
01:34 cschneid_ joined
01:35 peterbecich joined
01:38 juanpauc_ joined
01:40 Youmu joined
01:42 bumpkin- left
01:42 bumpkin left
01:43 juanpaucar joined
01:47 juanpauc_ joined
01:48 takle joined
01:50 <Squarism> jle`, i get it.
01:50 <Squarism> thanks
01:52 eacameron joined
01:52 juanpaucar joined
01:53 qwertydvorak left
01:55 <Squarism> someone told me haskell evaluates "as far as it needs". Ie pattern matching a constructor doesnt evaluate fields. I see this as a way to go around that. =D
01:55 takle joined
01:56 <jle`> mhm, i think of it as a hook you can hack into the runtime system, sometimes
01:57 juanpauc_ joined
02:01 juanpaucar joined
02:02 martinga_ joined
02:03 alasi joined
02:04 drman joined
02:06 juanpauc_ joined
02:09 louispan joined
02:10 mimi_vx joined
02:10 fbergmann joined
02:10 juanpaucar joined
02:15 juanpauc_ joined
02:20 juanpaucar joined
02:22 exferenceBot joined
02:24 juanpauc_ joined
02:27 louispan joined
02:27 hexagoxel joined
02:27 MotherFlojo joined
02:29 juanpaucar joined
02:31 takle joined
02:33 juanpaucar joined
02:38 juanpaucar joined
02:39 takle joined
02:43 juanpaucar joined
02:47 juanpaucar joined
02:52 juanpaucar joined
02:56 juanpauc_ joined
03:01 juanpaucar joined
03:02 takle joined
03:02 conal joined
03:03 geekosaur joined
03:06 juanpauc_ joined
03:07 pranitbauva1997 joined
03:07 conal joined
03:10 takle joined
03:10 juanpaucar joined
03:12 saussure joined
03:15 juanpaucar joined
03:19 juanpaucar joined
03:20 louispan joined
03:21 aarvar joined
03:24 cschneid_ joined
03:24 juanpauc_ joined
03:24 cschneid_ joined
03:27 takle joined
03:28 systemfault joined
03:29 juanpaucar joined
03:32 drman joined
03:33 juanpaucar joined
03:37 takle joined
03:38 juanpauc_ joined
03:40 louispan joined
03:42 juanpaucar joined
03:47 juanpauc_ joined
03:47 takle joined
03:52 juanpaucar joined
03:56 juanpaucar joined
03:57 takle joined
03:57 mtg joined
03:58 conal joined
03:59 louispan joined
04:00 n_blownapart joined
04:01 juanpaucar joined
04:02 <n_blownapart> hi is using atom haskell ide plugins now working well with stack? a few months ago it was buggy
04:06 juanpauc_ joined
04:06 Tai joined
04:10 takle joined
04:10 juanpaucar joined
04:11 saussure joined
04:15 juanpaucar joined
04:18 louispan joined
04:19 juanpaucar joined
04:24 juanpaucar joined
04:28 juanpaucar joined
04:33 juanpauc_ joined
04:38 juanpaucar joined
04:42 juanpauc_ joined
04:47 juanpaucar joined
04:47 JoelMcCracken joined
04:50 mtg joined
04:51 juanpaucar joined
04:52 cschneid_ joined
04:54 bkboggy joined
04:56 juanpauc_ joined
05:01 juanpaucar joined
05:05 juanpaucar joined
05:05 mjora7 joined
05:06 MotherFlojo joined
05:06 saussure joined
05:10 louispan joined
05:10 juanpaucar joined
05:14 juanpaucar joined
05:15 saussure joined
05:18 saussure joined
05:19 juanpaucar joined
05:20 Kuros` joined
05:23 meandi_2 joined
05:24 juanpaucar joined
05:28 juanpauc_ joined
05:30 MotherFlojo joined
05:33 juanpaucar joined
05:38 juanpaucar joined
05:42 juanpauc_ joined
05:47 juanpaucar joined
05:51 juanpaucar joined
05:53 ThomasLocke joined
05:56 juanpauc_ joined
06:01 juanpaucar joined
06:05 juanpauc_ joined
06:10 juanpaucar joined
06:10 takle joined
06:14 juanpauc_ joined
06:18 nomotif joined
06:19 juanpaucar joined
06:24 juanpaucar joined
06:24 <thang1> That intermediate haskell book looks interesting
06:28 grizwako joined
06:28 juanpauc_ joined
06:33 juanpaucar joined
06:34 <glguy> why's that?
06:35 takle joined
06:37 juanpaucar joined
06:42 juanpauc_ joined
06:44 louispan joined
06:44 takle joined
06:46 juanpaucar joined
06:51 juanpauc_ joined
06:52 <thang1> Well it's always nice to have more books and stuff to look at for Haskell
06:53 <thang1> the more high quality learning materials, the better. Plus, Haskell seems to have a ton of beginner materials relative to the intermediate level
06:56 juanpaucar joined
06:57 <thang1> On the other hand, I don't know who Vlad and Artyom are and how good they are at writing books, so I'm cautiously optimsitic but not much more than that. Further, I don't know if they're just writing to make a profit or writing because they want to put better information out. If it's the latter, I'm more inclined to make the book open source so that the book's content is dynamically generated from
06:57 <thang1> a continuously evolving crowd-sourced material. Otherwise a book emphasizing standard practices for working with certain problems and "standard" libraries is going to be hopelessly out of date real damn quick.
07:00 juanpaucar joined
07:05 juanpaucar joined
07:07 eacameron joined
07:07 pbrant joined
07:08 takle joined
07:09 juanpaucar joined
07:12 takle joined
07:14 juanpauc_ joined
07:16 Pupnik joined
07:18 <LiaoTao> Is there any way to make a function a -> b call f.ex. read :: b, depending on the resolved type b?
07:18 <LiaoTao> Template Haskell territory?
07:19 juanpaucar joined
07:19 madjestic joined
07:21 haskelleksah joined
07:23 juanpauc_ joined
07:27 <LiaoTao> The function wouldn't be (a -> b), but rather (a -> MyType b), where I'd like to use read :: b
07:28 juanpaucar joined
07:30 mattyw joined
07:31 <mjora7> Hi, why does stack take so much longer to install packages than something like npm? I don't think I've ever waited longer than 60 seconds for a node application to fully install all of its dependencies. It seems like waiting for stack to install all the dependencies of something (like Scotty or Yesod) can take many minutes (like it just took 5 minutes to install the latter).
07:31 <mjora7> Is there just something wrong with my setup? Or is this expected.
07:32 juanpaucar joined
07:34 <jle`> LiaoTao: not sure what you mean exactly
07:34 <jle`> 'read' already can be implemented for different types
07:37 juanpaucar joined
07:37 <LiaoTao> jle`: I'm doing parsing with readMaybe and would like to match against a series of Symbol type constructors
07:37 <LiaoTao> It's probably not a very good way of going about this
07:37 <jle`> still not super sure what you want, sorry :|
07:37 <jle`> can you give an example
07:38 <LiaoTao> Sure, hold on
07:40 Levex joined
07:41 <lpaste> LiaoTao pasted “Parsing example” at http://lpaste.net/355661
07:41 <LiaoTao> jle`: ^
07:41 <LiaoTao> Ignore the -3>, don't know where it came from
07:42 juanpaucar joined
07:43 <jle`> hm, what are some example inputs and outputs from parse?
07:43 <LiaoTao> jle`: It's supposed to be parseLiteral
07:43 <jle`> btw, Maybe ('MkConstant a) is a kind error
07:43 <LiaoTao> Did some refactoring and forgot to rename it
07:43 <jle`> yeah, what are some example inputs and ouputs?
07:43 <jle`> Maybe :: * -> *
07:44 <jle`> but MkConstant :: (Show a, Num a, Ord a) => a -> Symbol
07:44 <jle`> so the kind of `MkConstant a` is Symbol
07:44 <LiaoTao> Like "45678" would turn into the corresponding Integer
07:44 <LiaoTao> Right
07:44 <LiaoTao> I'm on very shaky ground here, I realize
07:45 <jle`> ok so if i gave `parseLiteral "45678"`, what would the result be?
07:46 juanpaucar joined
07:46 <LiaoTao> jle`: MkConstant 45678
07:46 bvad joined
07:47 <LiaoTao> I'll try to rewrite it for a moment - please hold the help for now!
07:47 <LiaoTao> Thanks!
07:47 <jle`> np :)
07:48 <LiaoTao> Also, it probably should be 'Just MkConstant 45678'
07:48 <LiaoTao> Forgot the Maybe
07:49 merijn joined
07:49 colt44 joined
07:50 <jle`> so :: Maybe Symbol ?
07:50 <LiaoTao> jle`: Already changed it
07:50 <LiaoTao> I figure I need to match it while readMaybe returns Nothing, so a do-expression would be a good idea
07:51 juanpaucar joined
07:51 <jle`> do, or maybe just a pattern match
07:51 <jle`> w/ a case statement
07:52 <LiaoTao> I first tried the case statement, but wouldn't that make an ugly indentation mess?
07:52 <jle`> hm yeah, depends on how many nests you have
07:53 mlehmk joined
07:55 <merijn> If you find yourself nesting a lot of cases you can usually invent a helper for that
07:55 juanpauc_ joined
07:57 <LiaoTao> Hmm, I think the issue arises when trying to differentiate between different types of numbers
07:58 eacameron joined
07:58 <LiaoTao> I.e. I'm trying to implement parseLiteral that works for both Integers and Floats
07:59 <LiaoTao> parseLiteral "123" would return Just MkConstant 123 and parseLiteral "1.23" would return Just MkConstant 1.23
07:59 <LiaoTao> parseLiteral "abc" would return Nothing
08:00 <merijn> LiaoTao: that's not something you can easily do
08:00 juanpaucar joined
08:00 <merijn> This requires the type returned by parseLiteral to depend on it's input, which isn't possible in Haskell
08:05 juanpaucar joined
08:05 <LiaoTao> jle`,merijn a nested case statement worked
08:05 <LiaoTao> I just hope I don't need any more types!
08:06 <lpaste> LiaoTao pasted “Ugh” at http://lpaste.net/355664
08:06 thc202 joined
08:07 malaclyps joined
08:07 <LiaoTao> merijn: That's a good answer to my original question, thanks!
08:07 nickolay joined
08:07 <merijn> What's the type of MkConstant? Seems weird that this typechecks, tbh :p
08:08 <LiaoTao> merijn: Symbol :D
08:08 <LiaoTao> GADTs
08:08 <LiaoTao> merijn: http://lpaste.net/355661
08:08 <LiaoTao> That's the original paste
08:09 <merijn> ah, right :)
08:09 juanpaucar joined
08:10 <LiaoTao> I daren't imagine how much twiddling you'd have to do in C to get this
08:10 <LiaoTao> Haskell less than three
08:14 madjestic joined
08:14 juanpaucar joined
08:18 juanpaucar joined
08:23 pie_ joined
08:23 juanpaucar joined
08:26 eacameron joined
08:28 juanpaucar joined
08:32 juanpaucar joined
08:36 nacon joined
08:37 juanpaucar joined
08:37 grdryn joined
08:37 Gurkenglas joined
08:41 juanpauc_ joined
08:46 juanpaucar joined
08:47 romank joined
08:51 juanpaucar joined
08:51 ridho joined
08:55 juanpauc_ joined
08:56 fotonzade joined
09:00 juanpaucar joined
09:05 juanpaucar joined
09:09 takle joined
09:09 juanpaucar joined
09:14 juanpauc_ joined
09:18 takle joined
09:18 juanpaucar joined
09:22 birdgg joined
09:23 juanpaucar joined
09:27 mattyw joined
09:27 juanpauc_ joined
09:32 juanpaucar joined
09:37 juanpaucar joined
09:41 kareeeeem joined
09:41 juanpauc_ joined
09:46 juanpaucar joined
09:50 juanpaucar joined
09:55 juanpaucar joined
09:59 juanpauc_ joined
10:04 juanpaucar joined
10:05 takle joined
10:09 juanpauc_ joined
10:13 juanpaucar joined
10:18 juanpaucar joined
10:20 prophile joined
10:22 juanpaucar joined
10:26 takle joined
10:27 juanpaucar joined
10:32 juanpauc_ joined
10:32 takle joined
10:33 takle joined
10:36 <LiaoTao> So I've got a function that returns (Maybe a) and want to use it to create a StateT [b] Maybe a value
10:36 <LiaoTao> return makes it a StateT [b] Maybe (Maybe a) value, though
10:36 <LiaoTao> Can you join these in some way?
10:36 <merijn> :t StateT
10:36 <lambdabot> (s -> m (a, s)) -> StateT s m a
10:36 juanpaucar joined
10:37 <merijn> LiaoTao: You have to wrap it via StateT explicitly
10:37 <merijn> Or maybe lift can work?
10:37 <merijn> :t lift
10:37 <lambdabot> (Monad m, MonadTrans t) => m a -> t m a
10:37 <merijn> right
10:37 <merijn> :t lift `asAppliedTo` (Just True)
10:37 <lambdabot> MonadTrans t => Maybe Bool -> t Maybe Bool
10:40 <LiaoTao> It works, but I'm not sure how it works
10:40 <LiaoTao> Is it like pure and return, except for wrapping monads?
10:40 <merijn> It's for lifting existing monadic values into a monad transformer
10:41 <LiaoTao> So exactly what I wanted? :D
10:41 <merijn> LiaoTao: "StateT s" is a transformer (and instance of MonadTrans)
10:41 juanpauc_ joined
10:41 <merijn> So you get "lift :: Maybe a => (StateT s) Maybe a" i.e. 'StateT s' corresponding to 't' in the original type
10:42 <LiaoTao> Yeah
10:42 <LiaoTao> Thanks!
10:43 <LiaoTao> runStateT popOperator "+Hello+"
10:43 <LiaoTao> Just ('+',"Hello+")
10:43 <LiaoTao> \o/
10:44 takle joined
10:45 dni- joined
10:46 juanpaucar joined
10:49 netheranthem joined
10:50 juanpauc_ joined
10:55 juanpaucar joined
10:57 Phillemann joined
10:57 louispan joined
10:58 <Phillemann> I have [String] and I'd like a [Int] from that. When there's an error, I'd like to have the String that failed. Is it best to write a function "String -> Either String Int" and then fold over the list?
10:58 <Phillemann> Not sure if that's the right approach.
10:59 takle_ joined
10:59 bvad joined
10:59 <Iceland_jack> you could map that function over the list, yes
10:59 juanpauc_ joined
11:00 <merijn> Phillemann: Sounds reasonable
11:00 <Iceland_jack> Do you want spoilers for String -> Either String Int?
11:00 <Phillemann> Map, okay, and then look for a Left and otherwise collect the Rights...
11:00 <Iceland_jack> or to implement it yourself
11:00 <merijn> Phillemann: Oh, you wanna fail if any of them fail?
11:00 <Phillemann> Yes.
11:00 <merijn> :t mapM -- :)
11:00 <lambdabot> (Monad m, Traversable t) => (a -> m b) -> t a -> m (t b)
11:01 <Phillemann> Sorry, I might not made it precise enough :)
11:01 <merijn> :t mapM `asAppliedTo` (undefind :: String -> Either String Int)
11:01 <lambdabot> error:
11:01 <lambdabot> • Variable not in scope: undefind :: String -> Either String Int
11:01 <lambdabot> • Perhaps you meant ‘undefined’ (imported from Prelude)
11:01 <merijn> :t mapM `asAppliedTo` (undefined :: String -> Either String Int)
11:01 <lambdabot> Traversable t => (String -> Either String Int) -> t String -> Either String (t Int)
11:01 <Iceland_jack> :t traverse Text.Read.readEither
11:01 alibabzo joined
11:01 <lambdabot> (Read b, Traversable t) => t String -> Either String (t b)
11:01 <merijn> That only reports the first failure, though
11:01 <Phillemann> That'd be all right, though.
11:01 <merijn> rather than all
11:01 <merijn> Phillemann: If you don't care about which failure, it's even easier
11:02 <merijn> :t mapM Text.Read.readMaybe
11:02 <lambdabot> (Read b, Traversable t) => t String -> Maybe (t b)
11:02 <merijn> Phillemann: That returns Nothing if any of the reads fail with Nothing :)
11:03 <Iceland_jack> >>> readEither @Int `traverse` ["123", "43"]
11:03 <Iceland_jack> Right [123,43]
11:03 <Phillemann> I don't care about which failure, but I'd like to output the failed string.
11:03 <Phillemann> As in: String "foo" is not a number, please check
11:03 <merijn> > mapM Text.Read.readMaybe ["1","23","47"] :: Maybe [Int]
11:03 <lambdabot> error:
11:03 <lambdabot> Not in scope: ‘Text.Read.readMaybe’
11:03 <lambdabot> No module named ‘Text.Read’ is imported.
11:04 <merijn> > mapM readMaybe ["1","23","47"] :: Maybe [Int]
11:04 <lambdabot> error:
11:04 <lambdabot> Variable not in scope: readMaybe :: [Char] -> Maybe Int
11:04 <Iceland_jack> Phillemann: readEither doesn't report the String, but that's an easy exercise to write
11:04 <merijn> @let import Text.Read (readMaybe)
11:04 <lambdabot> Defined.
11:04 <merijn> > mapM readMaybe ["1","23","47"] :: Maybe [Int]
11:04 <lambdabot> Just [1,23,47]
11:04 juanpaucar joined
11:04 <merijn> > mapM readMaybe ["1","23","foo"] :: Maybe [Int]
11:04 <lambdabot> Nothing
11:04 <Phillemann> Iceland_jack: Sure, tupling it up is easy.
11:04 <merijn> Phillemann: The either will only show the first failure, though :)
11:05 <merijn> Although you could use map combined with
11:05 <merijn> :t lefts
11:05 <lambdabot> [Either a b] -> [a]
11:05 <Iceland_jack> or Lift.Const
11:05 <Iceland_jack> 'Validation' Either
11:06 <Iceland_jack> If you want multiple errors, use this to convert from Either to "Errors" https://hackage.haskell.org/package/transformers-
11:07 <Phillemann> Oh, that looks very nice, didn't know about that type
11:07 mattyw joined
11:08 <merijn> There's also Validation in the either package :)
11:08 Gloomy joined
11:08 juanpauc_ joined
11:13 <colt44> I have a list of triples [(t1, t2, t3)] and I need to transform it into [(t1, [(t2, [t3])]. Is there such a function?
11:13 juanpaucar joined
11:16 ridho joined
11:18 juanpauc_ joined
11:23 juanpaucar joined
11:25 <merijn> colt44: Do you care about the order of the resulting list?
11:27 mattyw joined
11:27 juanpaucar joined
11:28 <colt44> merijn: only for the first element realy. but I can sort the list afterwards, if necessary.
11:29 <colt44> the thing is that I'm join three tables with esqueleto, and I need to build a three level, nested, json out of it
11:29 Gloomy joined
11:31 <merijn> colt44: I'd hack something together using Map.unionWith
11:31 <merijn> Turn [(t1, t2, t3)] into [(t1, (t2, [t3]))] (just singleton lists of t3
11:31 <merijn> And then collapse everything using unionWIth
11:32 <merijn> eh, maybe like
11:32 juanpaucar joined
11:32 <merijn> :t map (\(t1, t2, t3) -> (t1, M.singleton t2 [t3]))
11:32 <lambdabot> [(t1, k, t)] -> [(t1, M.Map k [t])]
11:33 <merijn> :t map (\(t1, t2, t3) -> M.singleton t1 (M.singleton t2 [t3]))
11:33 <lambdabot> [(k1, k, t)] -> [M.Map k1 (M.Map k [t])]
11:33 <merijn> :t M.unionWith (M.unionWith mappend)
11:33 <lambdabot> (Monoid a, Ord k, Ord k1) => M.Map k1 (M.Map k a) -> M.Map k1 (M.Map k a) -> M.Map k1 (M.Map k a)
11:33 <merijn> ANd then you can unwrap via M.toList
11:36 juanpaucar joined
11:41 Gloomy joined
11:41 juanpauc_ joined
11:46 juanpaucar joined
11:50 juanpauc_ joined
11:52 pie_ joined
11:55 juanpaucar joined
11:59 juanpauc_ joined
12:04 juanpaucar joined
12:08 juanpaucar joined
12:13 juanpauc_ joined
12:19 louispan joined
12:22 takle joined
12:23 takle joined
12:27 eacameron joined
12:34 dni- joined
12:35 juanpaucar joined
12:37 takle joined
12:42 kritzcreek joined
12:53 mtg joined
12:55 fotonzade joined
13:00 jarshwah joined
13:01 juanpauc_ joined
13:02 juanpaucar joined
13:15 Levex joined
13:31 carlomagno joined
13:34 jathan joined
13:41 iAmerikan joined
13:49 jarshwah joined
13:53 yellowj joined
13:57 saussure joined
13:59 takle joined
14:01 grizwako left
14:01 takle_ joined
14:04 takle joined
14:06 aarvar joined
14:10 eacameron joined
14:18 bvad joined
14:22 pilne joined
14:22 takle joined
14:23 cschneid_ joined
14:23 dni- joined
14:24 eacameron joined
14:28 blissdev joined
14:36 madjestic joined
14:38 malaclyps joined
14:45 uglyfigurine joined
14:45 Iceland_jack joined
14:47 takle joined
14:51 Gurkenglas joined
14:51 takle joined
14:59 takle joined
15:03 takle joined
15:05 takle joined
15:09 takle joined
15:13 cschneid_ joined
15:17 mtg joined
15:22 takle joined
15:48 pie_ joined
15:50 haskelleksah joined
15:56 saussure joined
15:58 louispan joined
16:00 takle joined
16:01 bumpkin joined
16:08 nomotif joined
16:12 dni- joined
16:17 ralu joined
16:26 takle joined
16:42 takle_ joined
16:49 argent0 joined
16:50 albertus1 joined
16:56 takle joined
16:57 kritzcreek joined
17:12 iAmerikan joined
17:26 pie_ joined
17:30 netheranthem joined
17:33 mstruebing joined
17:38 Tene left
17:38 zero_byte joined
17:43 ebw joined
17:44 takle joined
17:45 Levex joined
18:01 dni- joined
18:13 mstruebing joined
18:16 takle joined
18:20 takle joined
18:20 merijn joined
18:22 takle joined
18:25 Kuros` joined
18:30 uglyfigurine joined
18:32 juanpaucar joined
18:36 takle_ joined
18:39 malaclyps joined
18:51 takle joined
19:05 texasmynsted joined
19:06 mstruebing joined
19:08 erisco joined
19:13 m3tti joined
19:14 iAmerikan joined
19:27 peterbecich joined
19:27 grizwako joined
19:35 peterbecich joined
19:42 Levex joined
19:49 nickolay_ joined
19:50 dni- joined
19:50 Levex joined
19:53 Levex joined
19:56 grizwako joined
19:59 mstruebing joined
20:00 Levex joined
20:02 malaclyps joined
20:11 pranitbauva1997 joined
20:11 takle joined
20:13 carlomagno joined
20:17 sigmundv__ joined
20:17 wildlander joined
20:26 fotonzade joined
20:26 peterbecich joined
20:30 madjestic joined
20:37 nullcone joined
20:38 mstruebing joined
20:40 fotonzade joined
21:02 abhiroop joined
21:03 <abhiroop> I am trying to run a single Haskell file
21:04 <abhiroop> which involves some multi threading
21:04 <abhiroop> I tried `ghc -threaded -rtsopts -with-rtsopts=-4 Abc.hs`
21:04 <abhiroop> it creates Abc.hi and Abc.o files
21:05 <abhiroop> But it doesn't link them
21:05 <glguy> abhiroop: Make sure the name of the main module is Main
21:05 <geekosaur> if there is no Main module containing a 'main' CAF
21:05 <abhiroop> Its just 1 file
21:05 <geekosaur> (or you can use -main-is to change the module and CAF name)
21:05 <abhiroop> Should I call it Main?
21:05 <geekosaur> doesn't matter
21:06 <geekosaur> yes
21:06 <geekosaur> haskell is not a shell, haskell is not a simple scripting language that runs commands sequentially
21:06 <geekosaur> it's more like java where you need 'public static void main' or C where you need 'int main(int argc, char **argv)'
21:21 mjora7 joined
21:27 abhiroop_ joined
21:29 juanpaucar joined
21:31 pie_ joined
21:33 pie_ joined
21:35 saussure joined
21:39 dni- joined
21:39 mjora7 joined
21:53 hiratara joined
21:57 pilne joined
22:00 saussure joined
22:02 <saussure> Going through a Parser tutorial with the following : newtype Parser a = Parser { parse :: String -> [(a,String)] }
22:02 <saussure> This would be considered "record" syntax, right?
22:05 thaunatos joined
22:07 <thaunatos> Hello! I'm having trouble using the interact function. Typing then pressing enter doesn't print anything - but when I ctrl-c out the string is printed.
22:07 <thaunatos> I suspected this has to do with something called "laziness" but I'm not sure how to fix it.
22:08 <jle`> thaunatos: can you paste the code you're using?
22:08 <jle`> saussure: yes
22:08 <thaunatos> Here you go: http://lpaste.net/355690
22:09 <jle`> thaunatos: ah yeah it actually is from your terminal's buffering settings
22:09 <thaunatos> I'm also using Windows, in case that's relevant.
22:09 <jle`> normally, terminals buffer outputs
22:09 <jle`> they "buffer" all of the things they are supposed to print, and then print it all out at once when it receives a newline
22:10 <thaunatos> Ah. So I could just add a \n to print?
22:10 <jle`> when you do `printf "%0.2f" (typingDistance s)`, it sends whatever the distancec is to the terminal
22:10 <jle`> but the terminal won't print anything until it receives a newline
22:10 <jle`> yeah, printf "%0.2f\n" (typingDistance s) should force the buffer to flush
22:10 <jle`> assuming normal buffering settings
22:11 <jle`> this issue is unrelated to programming language; it has to do with the terminal you're using, or what you're running your program with. but admittedly it's not something that's taught very well when someone is learning how to program
22:13 <saussure> jle: in the above, you could pass a lambda to the "parse" to construct a value?
22:13 <saussure> a lambda that takes a string and returns a list of tuples that is.
22:15 <thaunatos> Hmm. Simply adding \n to the end of the format string didn't change the behavior.
22:16 <jle`> saussure: yes, you can pass in anything to Parser that has the right type
22:16 <jle`> using a lambda is one way to make a function of the proper type
22:16 <thaunatos> If I press enter twice after I enter the string, *sometimes* the answer is printed twice when I ctrl + c.
22:16 <jle`> but there are many others
22:21 <jle`> thaunatos: huh oh
22:21 <jle`> thaunatos: it looks like 'interact' does something different than what i expected
22:21 <jle`> it doesn't run the String -> String line-by-line
22:21 <jle`> it runs it on the entire input of stdin
22:21 <jle`> does not sound very useful
22:21 <jle`> you can use Ctrl+D to end your input
22:22 <jle`> you might have to write your own interact if you want line-by-line behavior
22:22 <thaunatos> Maybe. I tried forcing line buffering (using https://mail.haskell.org/pipermail/haskell/2003-September/012779.html) but that didn't seem to change anything.
22:22 <jle`> interact f = do l <- getLine; print (f l); interact f
22:22 <jle`> yeah it's not a line buffering issue, it's the fact that 'interact' is only run on the entire contents of stdin
22:22 <jle`> sorry about my previous guess earlier
22:22 <jle`> so even if you press enter, it takes the string you press as "blahblah\nblah blah"
22:26 takle joined
22:26 <thaunatos> That makes sense. I think that interact might have the behavior I expect when I run main with ghci.
22:27 <jle`> interact uses getContents, which has different behavior in different settings
22:27 <jle`> rather unfortunate
22:27 jship joined
22:28 albertus1 joined
22:28 <thaunatos> I'm going to run hlint on my program - I would be very grateful if you'd do a code review after I've made the suggested changes.
22:31 hiratara joined
22:33 <jle`> just paste it here :) if i'm not here, someone else probably will be
22:33 <thaunatos> Can do! Thank you so much for your help :-)
22:34 juanpaucar joined
22:36 uglyfigurine joined
22:40 <saussure> data Parser a = Parser { runParser :: String -> Maybe (a, String) }
22:40 <saussure> oneChar :: Parser Char
22:40 <saussure> oneChar = Parser $ \s -> case s of
22:40 <saussure> [] -> Nothing
22:40 <saussure> (c:xs) -> Just (c, xs)
22:41 <thaunatos> Hello! I've been working on daily programmer challenge #259 (link: https://www.reddit.com/r/dailyprogrammer/comments/4bc3el/)
22:41 <thaunatos> My solution is here: http://lpaste.net/355693
22:41 <thaunatos> I'd love to have a code review.
22:43 <saussure> I'm having difficulty following why runParser oneChar "Hello World" produces Just ("H", "ello world")
22:43 <saussure> I guess the sequence of calling runParser, the oneChar, then the String.
22:44 <jle`> saussure: what part do you not understnad?
22:44 <jle`> thaunatos: looks good :)
22:45 <jle`> i would have just used `printf " -> %.2fcm\n" (typingDistance s)` but i guess that's a style thing
22:45 <jle`> instead of 'tail', use 'drop 1'
22:45 <thaunatos> Why?
22:45 <jle`> tail is partial
22:46 mjora7 joined
22:46 <saussure> can you explain how "runParser" works? It almost seems like Parser is getting passed a Parser
22:46 <jle`> saussure: do you know how record syntax works?
22:46 <saussure> That might be my confusion
22:46 <saussure> I just can't follow this in my head...
22:46 <jle`> something like data Person = P { name :: String, age :: Int }
22:46 <jle`> do you know what that means?
22:47 <saussure> right: let x = P "Saussure" 31
22:47 <saussure> It builds a type of Person
22:47 <jle`> yeah
22:47 <jle`> what about name, age?
22:47 <jle`> what does name do?
22:48 <saussure> hmm. doesn't it just provide a function to retrieve the name value?
22:48 <jle`> mhm
22:48 <saussure> x name
22:48 <jle`> not quite
22:48 <jle`> 'name x'
22:48 <jle`> name :: Person -> String
22:48 <saussure> ah.
22:48 <jle`> so runParser is a function to retrieve the (String -> Maybe (a, String)) from the Parser a
22:49 <saussure> Yeah, I'm laughing to myself, because it's just not computing in my head.
22:50 <saussure> oneChar is of type Parser Char
22:50 <saussure> oneChar :: Parser Char
22:52 <thaunatos> Ooh zipWith exists
22:57 juanpaucar joined
22:57 <saussure> oh ok: so, runParser :: Parser a -> String -> Maybe (a, String)
22:59 <saussure> This could be read as: runParser is a function which takes a Parser a, and a String, and returns a Maybe (a, String) ??
23:19 saussure joined
23:21 iAmerikan joined
23:23 <glguy> saussure: basically. More specifically it's a function that takes a (Parser a) and returns a function that takes a String and returns a (Maybe (a, String))
23:26 fotonzade joined
23:28 dni- joined
23:43 uglyfigurine joined
23:49 nomotif joined
23:49 Gurkenglas joined
23:57 sync_ joined