Search Haskell Channel Logs

Saturday, February 11, 2017

#haskell channel featuring mangobot, tsahyt, systadmin, cocreature, lambdabot, mniip,

tsahyt 2017-02-10 23:45:24
yes
winny 2017-02-10 23:46:26
somebody mentioned my last pattern is not correct
mangobot 2017-02-10 23:46:42
mniip so i need to define an alterntive function to print that result?
piyush-kurur 2017-02-10 23:46:56
tsahyt: thanks is that a common style of releasing?
mniip 2017-02-10 23:47:07
mangobot, you claim to return [String] from parseFEN
mniip 2017-02-10 23:47:10
but you return String
mangobot 2017-02-10 23:47:31
mniip well i want to parse that string into [String]
mniip 2017-02-10 23:47:45
that's not what show does
piyush-kurur 2017-02-10 23:47:54
For example how do you know in the next release would you be making an breaking changes (which means bumping the A.B according to PVP)
piyush-kurur 2017-02-10 23:48:18
I am talking about packages in the initial stage of API stabilisation
mangobot 2017-02-10 23:48:26
mniip ok thanks
mangobot 2017-02-10 23:49:25
mniip any tips how can i print that list out? print doesnt work either
mangobot 2017-02-10 23:49:35
putStrLn?
mniip 2017-02-10 23:49:44
what are you trying to do
mniip 2017-02-10 23:50:03
parseFEN sounds like it should be parsing something
mniip 2017-02-10 23:50:10
that's not where you'd put "printing that list out"
tsahyt 2017-02-10 23:50:45
piyush-kurur: tbh I never bothered to check, it's just a natural way to do it in my mind.
mangobot 2017-02-10 23:50:56
mniip eventually i need to parse that string into [String] or ideally [[String]] and then parse each list for different purposes (board state, player color, move) so i want to check if that actually works in this test module
tsahyt 2017-02-10 23:51:00
you could just look around some repositories and see how different maintainers do it
mangobot 2017-02-10 23:51:13
mniip so i need a separate function to print it out?
mniip 2017-02-10 23:51:15
mangobot, do it with ghci
mniip 2017-02-10 23:51:18
or main
mniip 2017-02-10 23:51:34
you can't "debug printf" inside functions like that, not in haskell
mniip 2017-02-10 23:51:41
well you can but it's an entirely different story
mangobot 2017-02-10 23:51:49
mniip what would i write in the Predule if using ghci
tsahyt 2017-02-10 23:52:00
reminds me that I need to get rid of a myriad of trace statement that I've accumulated over the last two days...
mniip 2017-02-10 23:52:00
well,
mniip 2017-02-10 23:52:07
just call 'parseFEN' from ghci
mangobot 2017-02-10 23:55:52
mniip it says its not in scope ?
mangobot 2017-02-10 23:56:59
mniip ok it works, thanks fr the tip
mangobot 2017-02-11 00:04:53
if i use ghci, and then change the content of the hs file, do i need to quit and then call gchi again or can i compile it again without quiting?
mangobot 2017-02-11 00:04:56
make doesnt work
cocreature 2017-02-11 00:05:21
mangobot: :r
systadmin 2017-02-11 00:05:50
How do I print out the output of a variable?
cocreature 2017-02-11 00:06:05
systadmin: what is the output of a variable supposed to be?
cocreature 2017-02-11 00:06:12
:t print
lambdabot 2017-02-11 00:06:14
Show a => a -> IO ()
systadmin 2017-02-11 00:06:19
cocreature: a number
cocreature 2017-02-11 00:06:20
systadmin: maybe that's what you're looking for
systadmin 2017-02-11 00:07:43
http://sprunge.us/ZbhF?haskell this is the code
mangobot 2017-02-11 00:08:22
cocreature thanks!
cocreature 2017-02-11 00:08:33
systadmin: "print" should work
systadmin 2017-02-11 00:09:32
`print` followed by the variable?
cocreature 2017-02-11 00:09:39
yep
systadmin 2017-02-11 00:11:04
okay thanks!
cocreature 2017-02-11 00:11:27
systadmin: print is just putStrLn . show
systadmin 2017-02-11 00:12:57
Okay, I'm done with my code :D http://sprunge.us/OcOL?haskell
mangobot 2017-02-11 00:17:40
why does this work http://lpaste.net/352363 but when i use String-> [[String]] ghc says Couldn't match type 'Char' with '[Char]' Expected type: [String] Actual type: [Char] In the first argument of 'splitOn', namely '" "' In the expression: (splitOn " " str) In an equation for 'parseFEN': parseFEN str = (splitOn " " str)
cocreature 2017-02-11 00:19:22
mangobot: because it's the wrong type? I don't think I understood your question. you already seem to have figured out the correct type and just using another type isn't going to work
cocreature 2017-02-11 00:19:45
[[String]] also doesn't make a lot of sense. why should splitOn return a nested list?
mangobot 2017-02-11 00:21:05
cocreature ok i see, i thought i can change the type as i wanted to get [[string]]
cocreature 2017-02-11 00:21:25
mangobot: what do you expect splitOn to return in that case?
mangobot 2017-02-11 00:21:58
cocreature a list of lists split on " " ?
cocreature 2017-02-11 00:22:32
mangobot: you are giving it a single string, and you are splitting on " ". how do you expect to end up with a list of list of strings instead of only a list of strings?
mangobot 2017-02-11 00:24:04
cocreature so it cant split the string into lists but only a list ? i thought the same way it would split the string into a list of those strings but instead strings it would create lists
cocreature 2017-02-11 00:25:01
mangobot: let's take a concrete example, you are calling 'parseFEN "first second third"' and you want to get a [[String]] out of it. what is the exact result you expect?
mangobot 2017-02-11 00:25:27
cocreature [[b,b,b][b]]
cocreature 2017-02-11 00:26:05
mangobot: what? where do you get b from? parseFEN "first second third" is the same as splitOn " " "first second third"
mangobot 2017-02-11 00:27:10
cocreature ah i thought of the string from the code. well then [[first][second][third]]
cocreature 2017-02-11 00:27:34
mangobot: so you just want to wrap each word in a single item list?
mangobot 2017-02-11 00:27:44
cocreature yeah
mangobot 2017-02-11 00:27:56
and then parse those lists seperatly with different functions
cocreature 2017-02-11 00:28:04
mangobot: in that case you can first call splitOn and then "map (\x -> [x])" over the result
mangobot 2017-02-11 00:28:47
cocreature in the same function=
mangobot 2017-02-11 00:28:48
?
cocreature 2017-02-11 00:29:16
mangobot: sure, e.g. parseFEN str = map (\x -> [x]) (splitOn " " str)
mangobot 2017-02-11 00:29:51
cocreature ah awesome, thanks a lot
mangobot 2017-02-11 00:30:14
cocreature and if i want to access each list i use !! 0 , !! 1 etc?
cocreature 2017-02-11 00:31:14
mangobot: yep but usually lists are the wrong data structure if you want to do random access. accessing the nth element of a list requires scanning through the whole list before that element
mangobot 2017-02-11 00:32:02
cocreature the idea is to parse a string like "b,b,b,b w a3-c4" into a gamestate, player and move, so ithought i culd then apply the differnt functions ot each lists depending on the purpose
mangobot 2017-02-11 00:32:15
like to find the cooardinates for the next move etc