Search Haskell Channel Logs

Saturday, February 4, 2017

#haskell channel featuring myme, maerwald, kubbe, ph88, mniip, hexagoxel, and 5 others.

barrucadu 2017-02-04 10:46:42
Or in case of function names, foo' might be a slightly different version of foo
erisco 2017-02-04 10:47:11
or the strict version
kubbe 2017-02-04 10:47:42
what does "strict version" mean?
erisco 2017-02-04 10:48:15
it means it evaluates arguments before application
kubbe 2017-02-04 10:48:34
oh yeah, alright. thanks!
erisco 2017-02-04 10:48:43
at least somewhere, anyways, like in foldl'
kubbe 2017-02-04 10:49:43
i saw that example in a forum a minutes ago. Didnt really get what foldl and foldl' does, though. I think i will get it soon enough
ph88 2017-02-04 10:53:40
(try char '\\' >> char '\\') <|> otherCharsWithoutBackslash is this the right way to say that i have a string where backslashes must be escaped by themselves in a parser ?
erisco 2017-02-04 10:55:39
I don't think so. What about char '\\' >> char '\\' <|> otherCharsWithoutBackslash ?
ph88 2017-02-04 10:57:22
erisco, then char '\\' always consume 1 character even when it fails, no ?
erisco 2017-02-04 10:57:56
no
ph88 2017-02-04 10:58:13
oh
erisco 2017-02-04 10:58:16
char 'a' <|> char 'b' <|> char 'c' this recognises a, b, or c
ph88 2017-02-04 10:58:24
oh ye ok
ph88 2017-02-04 10:58:59
so it's only with strings that consume input ?
myme 2017-02-04 10:59:00
I have an IO action `a -> IO (Either String a)` and been wondering how you could write a fold of a list or traversible of these actions, terminating at the first `Left String`.
erisco 2017-02-04 10:59:10
no
erisco 2017-02-04 10:59:27
it depends on the parser, but most are lookahead 1
myme 2017-02-04 10:59:31
My intuition's telling me this can be solved in a more smooth way, but I'm so rusty I can't really see how atm.
ph88 2017-02-04 10:59:33
aah ok
ph88 2017-02-04 10:59:36
i use megaparsec
erisco 2017-02-04 10:59:55
this means that when you have alternation, i.e. a <|> b, it goes with a if the next character matches and goes with b otherwise
ph88 2017-02-04 11:00:13
ok thx erisco
myme 2017-02-04 11:00:35
(should've mentioned the `a`s are passed along to the consequtive action)
erisco 2017-02-04 11:01:07
so, depending on how the string parser is setup, string "abe" <|> string "ace" may fail to parse "ace"
erisco 2017-02-04 11:01:44
if it is implemented as char 'a' >> char 'b' >> char 'c' <|> char 'a' >> char 'c' >> char 'e'
ph88 2017-02-04 11:02:26
i use megaparsec which is a variation of parsec .. not sure what it does under the hood
geekosaur 2017-02-04 11:04:30
you need to use `try` on that, pretty sure
geekosaur 2017-02-04 11:04:51
otherwise on seeing "ace" the `string "abe"` parser will consume the "a" and fail
geekosaur 2017-02-04 11:04:59
and then the other starts at the "b:
ph88 2017-02-04 11:05:01
erisco, i implemented it like this atm https://paste.fedoraproject.org/546569/86245891/
ph88 2017-02-04 11:06:18
geekosaur, i think that's what erisco meant when he said that the parser string "abe" <|> string "ace" may fail to parse "ace"
geekosaur 2017-02-04 11:06:29
yes
ph88 2017-02-04 11:06:48
ok but in my case i only have a parser of a single character
kubbe 2017-02-04 11:06:59
what does "Monad" mean? i have tried looking it up but I cant really find an "easy" answer
erisco 2017-02-04 11:07:17
well that is because there are no easy answers, heh
ph88 2017-02-04 11:07:18
see line 41, line 57 and line 72
ph88 2017-02-04 11:07:36
oh oh i think i made a mistake on the 2nd and 3rd parser :/
barrucadu 2017-02-04 11:07:38
It's an abstraction that happens to be useful in many contexts
erisco 2017-02-04 11:07:43
kubbe, http://learnyouahaskell.com/a-fistful-of-monads
kubbe 2017-02-04 11:07:58
thank you!
kubbe 2017-02-04 11:08:21
oh, this is an entire guide with everything! thanks erisco
ph88 2017-02-04 11:08:25
kubbe, have you seen this http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html ??
kubbe 2017-02-04 11:09:54
Nope! I'll read that one aswell. thank you mate ph88
ph88 2017-02-04 11:09:58
np
barrucadu 2017-02-04 11:10:00
There's also https://wiki.haskell.org/Typeclassopedia
geekosaur 2017-02-04 11:10:25
@quote geekosaur _Category
lambdabot 2017-02-04 11:10:25
No quotes match. That's something I cannot allow to happen.
erisco 2017-02-04 11:10:26
I'm not sure their "Some Magic Happens" bubble is all that enlightening :P
geekosaur 2017-02-04 11:10:44
blegh. (it didn;t really belong in there anyway)
ph88 2017-02-04 11:10:53
kubbe, which other programming languages do you know? it might be possible to explain the monad in the language you are already familiar with
geekosaur 2017-02-04 11:10:57
2016 Nov 12 06:21:11 so fwiw it looks like he introduced it in _Category Theory for the Working Mathematician_, and his terminology note doesn't explain why he picked "monad", but perhaps can be understood to imply a sort of cross between "monoid" and "triad"
mniip 2017-02-04 11:11:01
monads are just monoids in the endofunctor monoidal category
geekosaur 2017-02-04 11:11:09
dug that out back then ("he" is Mac Lane)
mniip 2017-02-04 11:11:12
:)
kubbe 2017-02-04 11:11:15
erisco, hahah it is good enough for me atm.
geekosaur 2017-02-04 11:11:35
oh
kubbe 2017-02-04 11:11:35
ph88, html css javascript and (some) c++
geekosaur 2017-02-04 11:11:45
@quote geekosaur _Categories
lambdabot 2017-02-04 11:11:45
geekosaur says: so fwiw it looks like [Mac Lane] introduced it in _Categories for the Working Mathematician_, and his terminology note doesn't explain why he picked "monad", but perhaps can be
lambdabot 2017-02-04 11:11:45
understood to imply a sort of cross between "monoid" and "triad". (p.138 at http://www.maths.ed.ac.uk/~aar/papers/maclanecat.pdf)
mniip 2017-02-04 11:11:52
kubbe, you familiar with C++ template metaprogramming?
geekosaur 2017-02-04 11:12:27
probably makes more sense as a @where...
kubbe 2017-02-04 11:12:33
mniip, nope! Cant say I am
mniip 2017-02-04 11:12:44
well damn, that would've been a decent explanation
ph88 2017-02-04 11:12:49
kubbe, if you google like javacript monad you will find a few things as well
maerwald 2017-02-04 11:13:09
oh god :D
mniip 2017-02-04 11:13:20
javascript monad?
kubbe 2017-02-04 11:13:26
alrighty then, im on it. thanks guys
mniip 2017-02-04 11:13:29
what's that, State (Map Dynamic Dynamic) ?
maerwald 2017-02-04 11:13:29
that's like googling "haskell duck typing"
ph88 2017-02-04 11:13:46
Data.Dynamic no ? :p
systemfault 2017-02-04 11:13:48
"Promise" in JavaScript is very close to be a monad.
barrucadu 2017-02-04 11:13:50
I have been doing terrible things with Typeable and Dynamic lately...
geekosaur 2017-02-04 11:13:55
acme-php :p
kubbe 2017-02-04 11:14:07
mniip, haha i'll get back to you when I know that aswell
ph88 2017-02-04 11:14:09
barrucadu, tell us more :D
erisco 2017-02-04 11:14:25
it is except that it is usually used for side effects
barrucadu 2017-02-04 11:15:01
ph88: Have you come across QuickSpec? It's a little tool which takes a collection of functions and values, and discovers properties that they satisfy, by generating and testing expressions.
barrucadu 2017-02-04 11:15:38
ph88: I'm trying to do something similar for concurrent data structures, which means I'm generating monadic expressions, and it's all very dynamically typed as I try to make everything fit
mniip 2017-02-04 11:15:53
kubbe, one of the main ideas is that, like, in C++, while std::list is a concrete type, std::list is not, it is a type constructor, and it is parameterizable with whatever type you want contained in the list
kubbe 2017-02-04 11:16:42
mniip, hmm alright. I can understand that
ph88 2017-02-04 11:16:43
barrucadu, have you come across hipspec? it's a little tool which takes your quickspec output and formally verifies it with a theorem prover
barrucadu 2017-02-04 11:17:07
ph88: I've seen it, but not used it. It does look pretty cool.
mniip 2017-02-04 11:18:16
kubbe, perhaps we could pop into #haskell-beginners where it's less noisy
ph88 2017-02-04 11:18:16
barrucadu, i've watched a video online the other day which was very interesting .. it was about how theorem proving meets concurrent designs .. the guy eventually came up with a language in which you can define a lot of stuff for that
ph88 2017-02-04 11:18:29
shall i find it for you ?
kubbe 2017-02-04 11:18:41
alright, sounds like a good idea. didnt know that channel existed! cya there
barrucadu 2017-02-04 11:18:58
ph88: If it wouldn't be inconvenient
hexagoxel 2017-02-04 11:26:40
myme: can only think of EitherT + iterateM_, but that is not very pretty.
myme 2017-02-04 11:27:31
hexagoxel: Been looking at Control.Monad.Trans.Either from `either`.
myme 2017-02-04 11:27:37
Yes.
myme 2017-02-04 11:28:36
The folding may not be that cruical though. The number of steps is deterministic and few. It's basically for writing some tests more pretty than nesting `case`s or something similar.
ph88 2017-02-04 11:34:58
barrucadu, https://www.youtube.com/watch?v=R2Aa4PivG0g related is this language which followed from the stuff this guy talks about http://bloom-lang.net/
barrucadu 2017-02-04 11:38:46
ph88: Thanks, I'll check it out