Search Haskell Channel Logs

Thursday, February 9, 2017

#haskell channel featuring Myrl-saki, Freundlich, yaxu, Profpatsch, srhb, ocharles, and 5 others.

srhb 2017-02-09 01:52:07
I guess my question is, how do I split the [Event] up into individual Event in the conduit?
srhb 2017-02-09 01:52:18
Something like mapM_ yield...
ocharles 2017-02-09 01:58:50
Can anyone help me work out wtf is going on with my `cabal repl` here?
ocharles 2017-02-09 01:58:53
https://www.irccloud.com/pastebin/TsUVsvs4/
ocharles 2017-02-09 01:59:35
`private :: Int` in Application.Aws, but it's not in exports. So I need Application.Aws interpreted, so I can access non-exported symbols. I get that much. What I don't get is why :add * is giving me a completely useless error
ondraa 2017-02-09 02:00:16
hello. Let `type FilePath = String`, let Path be a type, instance of IsString, let f : Path -> Path and fp : FilePath. Then `f fp` does not typecheck (expects Path, actual is FilePath). How can I go around this?
Myrl-saki 2017-02-09 02:03:01
ondraa: `let g : FilePath -> Path` ?
kubbe 2017-02-09 02:04:41
Hi guys! How can I return a random INT between 1 and 20? I have tried importing System.Random and then use the randomRIO (1,20) but it doesnt work.
AndreasK 2017-02-09 02:05:43
kubbe: What exactly doesn't work
Freundlich 2017-02-09 02:05:46
kubbe: Doesn't work?
kubbe 2017-02-09 02:06:04
2 seconds, Im gonna put it in a pastebin
ondraa 2017-02-09 02:06:05
Myrl-saki: how do I define g then? Without the call to the fromString implemented for Path as the library I use does not export it.
kubbe 2017-02-09 02:06:48
AndreasK Freundlich http://pastebin.com/3vD9HtKv
Myrl-saki 2017-02-09 02:07:09
Hmmm
ondraa 2017-02-09 02:07:12
here's the example in code http://lpaste.net/352274
Myrl-saki 2017-02-09 02:07:31
kubbe: `main = randomRIO(1,20)`
kubbe 2017-02-09 02:07:38
it cant compile in GHCI, it says its: "Parse error: naked expression blablablba"
AndreasK 2017-02-09 02:07:42
I'm trying to use the GHC Api to get the AST for some haskell code, however pretty much all of the api requires DynFlags, is there an easy way to construct default dynflags?
kubbe 2017-02-09 02:07:42
oh. Alright!
Myrl-saki 2017-02-09 02:08:09
ondraa: `g (Path s) = s`?
Myrl-saki 2017-02-09 02:08:44
ondraa: OverloadedStrings don't make any IsString instance be usable as String.
Myrl-saki 2017-02-09 02:09:14
ondraa: It means anything that can be parsed as a String can be compile-time made into an IsString instance. Correct me if I made an imprecise statement.
kubbe 2017-02-09 02:09:54
Myrl-saki, it cant compile when I try that. GHCI gives me the worlds longest error message
yaxu 2017-02-09 02:10:02
Hello, wondering if there's an easy way to 'compress' haskell? Particularly to remove unnecessary whitespace to help playing code golf (in this case writing music for tidalbot - http://twitter.com/tidalbot)
Reisen 2017-02-09 02:10:27
Is it possible to do this: http://stackoverflow.com/a/3467806 -- but with types using GADT's and type families?
Myrl-saki 2017-02-09 02:10:38
kubbe: How exactly are you using it?
Myrl-saki 2017-02-09 02:10:51
kubbe: In reality, you'd do something like..
AndreasK 2017-02-09 02:11:31
main is expecting type "IO ()" not "IO a" I think
Myrl-saki 2017-02-09 02:12:19
AndreasK: Oh. I thought main is IO a? ._.
kubbe 2017-02-09 02:12:31
When i import System.Random I can compile it and get a random int directly in GHCI. But i want to use it in a function.
Myrl-saki 2017-02-09 02:12:34
I tried it out myself, and it seems to be a type error.
Myrl-saki 2017-02-09 02:12:36
Err
kubbe 2017-02-09 02:12:39
Can I convert a randomRIO into a INT?
Myrl-saki 2017-02-09 02:12:42
A type prediction error
Myrl-saki 2017-02-09 02:12:43
whatsoever.
AndreasK 2017-02-09 02:12:52
main :: IO () yep
Myrl-saki 2017-02-09 02:12:54
kubbe: Yes.
Myrl-saki 2017-02-09 02:13:07
kubbe: `randomRIO (1,20) :: IO Int`
Myrl-saki 2017-02-09 02:13:47
AndreasK: https://ideone.com/Z4oRVT
Myrl-saki 2017-02-09 02:13:51
kubbe: ^
kubbe 2017-02-09 02:13:52
oh, well thanks. This should solve the problem!
Myrl-saki 2017-02-09 02:14:06
AndreasK: `main :: IO Int`
ondraa 2017-02-09 02:14:17
Myrl-saki: this choice of `g` changes the problem to Expected: Path, actual ByteString :- / (this is the Path http://hackage.haskell.org/package/libmpd-0.9.0.6/docs/Network-MPD.html#t:Path)
Myrl-saki 2017-02-09 02:14:18
I wonder if I can use this to return error codes though.
ondraa 2017-02-09 02:14:46
Myrl-saki: thanks for the OverloadedStrings explanation
kubbe 2017-02-09 02:15:04
Myrl-saki what does the last line do? The one 'randomRIO (1,30)'. After the last print where you add the x and y?
Myrl-saki 2017-02-09 02:15:16
kubbe: That was for AndreasK.
AndreasK 2017-02-09 02:15:27
I guess IO () was just the default then
kubbe 2017-02-09 02:15:30
Oh! Nvm then :)
Myrl-saki 2017-02-09 02:15:38
kubbe: Though, that's how you can specify that randomRIO (x,y) to retun an IO Int.
ondraa 2017-02-09 02:15:49
Myrl-saki: moreover this `g` requires me to know how Path is implemented inside the library, which I would preferably like to avoid
Myrl-saki 2017-02-09 02:15:59
ondraa: Right.
Myrl-saki 2017-02-09 02:16:16
ondraa: Hmmm. Can you show me what you're working on so far?
kubbe 2017-02-09 02:17:48
Myrl-saki, this is the function that instead of giving me 4 I want a random INT between 1 and 20. : http://pastebin.com/igBynjrZ
Myrl-saki 2017-02-09 02:18:13
kubbe: Ah. This one's easy then. :(
Myrl-saki 2017-02-09 02:18:15
:)*
kubbe 2017-02-09 02:18:31
There is more code than this ofcourse, and I have imported system.random already. Should I save each and every random in 3 different variables?
Myrl-saki 2017-02-09 02:18:35
kubbe: There are many ways to approach to this.
Myrl-saki 2017-02-09 02:18:54
One is the `x <- randomRIO (1,20)` ... thing.
Myrl-saki 2017-02-09 02:19:23
kubbe: Do you know how to use monadic style already?
kubbe 2017-02-09 02:19:44
I am not sure what monadic style is.. so I say maybe!
Myrl-saki 2017-02-09 02:19:56
kubbe: Okay. Do you know how to use do-notation?
kubbe 2017-02-09 02:20:36
the do-notation is what we are supposed to get to know after this class!
Myrl-saki 2017-02-09 02:20:53
kubbe: That's... weird.
Myrl-saki 2017-02-09 02:21:00
kubbe: Hmmm.
Myrl-saki 2017-02-09 02:21:10
kubbe: Did your teacher teach you about applicatives and functors already?
kubbe 2017-02-09 02:21:30
the complete assignment is to modify the Nim-game, and one of the modifications is to get random amount of stones at each pile. random between 1 and 20
Myrl-saki 2017-02-09 02:21:32
Since for sanity purposes, we'd use do-notation to generate something into a tuple.
kubbe 2017-02-09 02:21:36
yes, more or less
Myrl-saki 2017-02-09 02:22:18
kubbe: Oh. Chances are, you're not supposed to generate the 3 numbers in one go.
kubbe 2017-02-09 02:23:23
Maybe! But I think I got a solution that works now. I did like you said with the "x<- randomRIO(1,20)...."
Myrl-saki 2017-02-09 02:23:25
kubbe: You can use `(,,) <$> randomRIO (1,20) <*> randomRIO (1,20) <*> randomRIO (1,20)` to actually generate 3 random numbers in 1 go without using do-notation though. But that's ugly and probably not what your teacher's looking for. :P
kubbe 2017-02-09 02:23:52
Haha yeah. This is the thing I made : http://pastebin.com/i6WMRdfR
Myrl-saki 2017-02-09 02:24:06
kubbe: Mhm. Good job.
Myrl-saki 2017-02-09 02:24:27
kubbe: Is GameState = (Int, Int, Int)?
kubbe 2017-02-09 02:24:41
Thank you for your help! Yes it is
Profpatsch 2017-02-09 02:24:55
Hm, when I'm in LoggingT IO a, can I run one action with (MonadLogger m) in NoLoggingT?
Myrl-saki 2017-02-09 02:25:12
kubbe: Then you don't have to put the IO Ints.
Profpatsch 2017-02-09 02:25:15
I'm certain it's possible, but I can't wrap my head around it.
kubbe 2017-02-09 02:25:37
Oh, yeah i noticed now that I got error on that part. It cant match the types IO Int with INT
Myrl-saki 2017-02-09 02:26:02
kubbe: Mhm. IO Int is an "IO action that returns an int"
Myrl-saki 2017-02-09 02:26:48
kubbe: Think of the difference between `random() and random` in other languages. random() will return a random number while random will result in 4.
kubbe 2017-02-09 02:27:06
Yeah alright
ondraa_ 2017-02-09 02:27:58
Myrl-saki: Oh, I realized the problem is in a different place. I had two conflicting claims about types in the code but GHC assumed one is correct and deduced the other is wrong. What I actually want is to change the first claim.
ondraa_ 2017-02-09 02:28:11
Myrl-saki: thank you for your help!
Myrl-saki 2017-02-09 02:28:45
ondraa_: Oh. Hahaha. Glad to hear it's fixed.
kubbe 2017-02-09 02:30:39
Myrl-saki, I took away the IO Int from my randomRIO and it works. But why does it work? And now when I am trying to use the randomRIO in a different location it doesnt work. Let me give you the example
Myrl-saki 2017-02-09 02:31:44
kubbe: No need. I get the idea why.
Myrl-saki 2017-02-09 02:31:50
kubbe: Thing is, numbers are unique.
Profpatsch 2017-02-09 02:31:52
Myrl-saki: My brain auto-corrected your nick to "Miyazaki" on first glance
Myrl-saki 2017-02-09 02:32:07
Profpatsch: That'd be awesome since I'm learning how to draw!
Profpatsch 2017-02-09 02:32:23
But can you learn how to Ghibli?
Myrl-saki 2017-02-09 02:32:26
kubbe: Numbers can manifest into any numerical type.
Myrl-saki 2017-02-09 02:32:39
Profpatsch: Nope, but so far, my necks are broken so I can shaft.
Myrl-saki 2017-02-09 02:33:19
kubbe: So basically, it gets confused as to which code will be used. For Floats, Ints, etc.
Profpatsch 2017-02-09 02:34:16
Myrl-saki: I hope that brings you money for special FX, so you can ufotable it up a bit.
kubbe 2017-02-09 02:34:23
Ohh.. alright! No wonder this get pretty confusing when learning this. Let me give you another example
Myrl-saki 2017-02-09 02:34:50
kubbe: Mhm. It's kinda funny when type inferrence is what makes you confused.
Myrl-saki 2017-02-09 02:35:10
kubbe: I think it happens to anyone no matterh ow long they've used Hs.
kubbe 2017-02-09 02:35:28
Myrl-saki, so in this code when the computer is supposed to make its move I want it to move a random int from 1 to 3.. http://pastebin.com/555Ykker
kubbe 2017-02-09 02:35:34
Hahah okey!
Myrl-saki 2017-02-09 02:35:37
Profpatsch: Or I could learn more structural parts and make mechs and give it a bit of sunrise.
Profpatsch 2017-02-09 02:36:15
Yeah, that would make your popularity A-1-explode, I'm sure of it.
Myrl-saki 2017-02-09 02:36:34
Profpatsch: Aaand I'm out of studios. xD
Profpatsch 2017-02-09 02:37:14
So much potential left. :)
Myrl-saki 2017-02-09 02:37:38
Profpatsch: I'm not a fan of looking at studios. More of authors. :P
Myrl-saki 2017-02-09 02:37:53
kubbe: to move a random int from 1 to 3?
kubbe 2017-02-09 02:38:37
yes!
Myrl-saki 2017-02-09 02:38:54
kubbe: What do you mean by that?
kubbe 2017-02-09 02:40:27
Oh.. So the computer is supposed to be locked to only move 1 to 3 stones from the pile. Therefore a random between (1,3) instead of a, b or c
Profpatsch 2017-02-09 02:40:45
Myrl-saki: https://www.youtube.com/watch?v=bpQK9SA9Hhw
Profpatsch 2017-02-09 02:40:49
You might enjoy that.
Myrl-saki 2017-02-09 02:41:45
Profpatsch: I'll take a look at it in a day or two. Internet got cut off and I'm using my mobile plan.
Myrl-saki 2017-02-09 02:43:23
kubbe: Welp. At least you've learned something in advance. xD