Search Haskell Channel Logs

Tuesday, February 21, 2017

#haskell channel featuring browndawg, fizbin, pikajude, mbrock, mroman, phadej, and 10 others.

mroman 2017-02-21 08:00:41
http://codepad.org/oIUm5mMB <- I feel like passing 8 arguments asks for Monads of some sort .
pikajude 2017-02-21 08:02:08
well, you could use Reader
byorgey 2017-02-21 08:02:19
mroman: nested pattern-matching on Nothing/Just also calls for using the Maybe monad
c_wraith 2017-02-21 08:02:44
mroman, do you have to pass all of those?
mroman 2017-02-21 08:03:01
Yes.
c_wraith 2017-02-21 08:03:19
mroman, a quick glance made it look like checkBinOp' could just close over most of its arguments
mroman 2017-02-21 08:03:54
it passes on the other arguments to checkTypes
byorgey 2017-02-21 08:04:00
mroman: it looks to me like you want to create a custom monad which is something like newtype TC a = TC (ReaderT stuff (ExceptT String) a)
c_wraith 2017-02-21 08:04:16
it can do that without receiving them as arguments.
mroman 2017-02-21 08:04:33
c_wraith: hu?
mroman 2017-02-21 08:04:43
with a State Monad of some sort probably.
mroman 2017-02-21 08:04:48
or what else are you refering to?
c_wraith 2017-02-21 08:05:19
mroman, just define checkBinOp' in the let block.
c_wraith 2017-02-21 08:05:33
mroman, then all those definitions are already in scope
mroman 2017-02-21 08:05:39
oh. right.
c_wraith 2017-02-21 08:05:57
or alternatively, define everything else in the where block.
c_wraith 2017-02-21 08:06:58
you still might want a monad, but you can simplify things first. :)
mroman 2017-02-21 08:07:49
yeah.
mroman 2017-02-21 08:08:09
that'll also allow for more convenience function such as bindType and stuff like that.
mroman 2017-02-21 08:08:18
instead of doing inserts all day long.
johnw 2017-02-21 08:08:57
byorgey: did you mean: newtype TC m a = TC (ReaderT stuff (ExceptT String m) a)?
mroman 2017-02-21 08:09:45
I hope I used the term polymorphic type correctly :)
mroman 2017-02-21 08:09:57
I have no real CS background.
mroman 2017-02-21 08:12:46
and I should probably allow type classes to contain other type classes.
mroman 2017-02-21 08:15:32
and it would be nice to allow circular imports :)
phadej 2017-02-21 08:16:28
there is .hs-boot
phadej 2017-02-21 08:16:39
but I don't think it's agood idea
phadej 2017-02-21 08:18:07
at least I didn't needed them ever, and the average file has ~100 lines at work
phadej 2017-02-21 08:18:13
so you can break the cycles quite well in practive
phadej 2017-02-21 08:18:17
practice*
mroman 2017-02-21 08:18:37
most of the time you can just pull stuff out into a third module and break the cycle that way
johnw 2017-02-21 08:18:42
I've used .hs-boot from time to time
johnw 2017-02-21 08:18:44
can be very useful
mroman 2017-02-21 08:18:50
or combine the two modules into one.
mroman 2017-02-21 08:19:21
not that I'd really use haskell for anything productive.
johnw 2017-02-21 08:19:38
why not?
mroman 2017-02-21 08:20:06
few people know it.
mroman 2017-02-21 08:20:25
strength of a language is a.) libraries b.) amount of people who know it.
jle` 2017-02-21 08:20:38
that hasn't stopped me from using haskell for everything productive i do heh
johnw 2017-02-21 08:20:46
not really sure how languages become strong, by that logic...
mroman 2017-02-21 08:21:10
I personally think all languages without a proper typesystem are complete crap.
mroman 2017-02-21 08:21:47
but still many people use them.
mroman 2017-02-21 08:21:59
thus I have to use them.
jle` 2017-02-21 08:22:18
i'm feeling like i'm missing a step in logic here
jle` 2017-02-21 08:22:21
1. many people use them
jle` 2017-02-21 08:22:23
2. ????
jle` 2017-02-21 08:22:26
3. i have to use them
jle` 2017-02-21 08:22:34
4. profit (?)
mroman 2017-02-21 08:22:47
Very few people hire you to write Haskell code.
sternmull 2017-02-21 08:22:49
i try to understand Pipes.Concurrent. In the tutorial there is a function "user" which seems to be called repeatedly when it gets "potion" as input. What causes this repeated calls? (This is the tutorial: https://hackage.haskell.org/package/pipes-concurrency-2.0.7/docs/Pipes-Concurrent-Tutorial.html)
mroman 2017-02-21 08:23:01
Very many people hire you to write javascript, python.
mroman 2017-02-21 08:23:21
and java. luckily java has a typesystem.
mroman 2017-02-21 08:24:25
and it's not like type systems are hard to implement.
srhb 2017-02-21 08:24:34
sternmull: Do you mean the recursive call?
srhb 2017-02-21 08:24:56
sternmull: Oh, no, on potion...
mbrock 2017-02-21 08:24:58
I'd think a Haskell-like type system is pretty hard to implement
johnw 2017-02-21 08:25:21
mbrock: for Haskell 2010 without extensions, not so terrible
sternmull 2017-02-21 08:25:25
srhb: Yes. What calls "user" when the input is "potion"?
srhb 2017-02-21 08:26:02
sternmull: There are many examples here... Is it this one? user = P.stdinLn >-> P.takeWhile (/= "quit")
mroman 2017-02-21 08:26:24
sure but c-like type systems are easy.
mbrock 2017-02-21 08:26:45
johnw: true, but you'll probably face a steady demand (as Haskell has) for new features, straddling the fractal tradeoff between inference and dependent types, etc
sternmull 2017-02-21 08:26:53
srhb: I mean "game.hs" in the appendix.
mroman 2017-02-21 08:27:06
nobody wants dependent types in practice anyway :D
srhb 2017-02-21 08:28:08
sternmull: The handler loops on a Heal event.
srhb 2017-02-21 08:28:54
sternmull: Heal n -> loop (health + n)
mroman 2017-02-21 08:29:44
inference is nice but most of the time it's fine if you have to write top level decls and let the compiler infer from that.
sternmull 2017-02-21 08:29:57
srhb: Ok... but isnt user called in another thread? As i understand it the "user" thread should terminate as soon as it processed "potion".
mbrock 2017-02-21 08:29:59
basically I think it's unfair to say languages without type systems are crap, because the work that goes into making Haskell's type system both ergonomic and powerful is enormous, and lots of cool stuff has been done in e.g. Smalltalk, Erlang, bash, you name it, that probably wouldn't have happened if their designers tried to fit everything into a type
mbrock 2017-02-21 08:29:59
formalism
mroman 2017-02-21 08:31:15
i.e. writing int foo(int a, int b) { c = a * b; return c; } is inference enough for most.
mroman 2017-02-21 08:31:40
mbrock: I don't like them because a.) it's unsafe b.) documentation
mroman 2017-02-21 08:31:56
I like to know what functions return.
mroman 2017-02-21 08:32:06
which I can't in languages like python
shapr 2017-02-21 08:32:29
mbrock: Weren't you at EuroHaskell 2003?
mroman 2017-02-21 08:32:32
(I also hate unchecked exceptions)
mbrock 2017-02-21 08:32:35
shapr: :) yes!
shapr 2017-02-21 08:32:37
I thought so
srhb 2017-02-21 08:32:52
sternmull: So if user doesn't find quit or heal or harm, it loops (consuming the next line from the input) but otherwise it's just "mapped" over the input stream
mbrock 2017-02-21 08:33:17
I saw John Hughes ride your unicycle!
shapr 2017-02-21 08:33:26
Yeah, many years ago
srhb 2017-02-21 08:33:46
sternmull: If there was never an invalid input, you could get rid of the recursive call in user and it would function the same
srhb 2017-02-21 08:34:06
sternmull: Does that make sense?
sternmull 2017-02-21 08:35:33
srhb: I still don't see it. When "user" sees "potion" it returns a "Heal 10" and i don't understand what calls it again. But according to the example output it is called until Quit is processed by the handler.
sternmull 2017-02-21 08:36:45
srhb: Does "lift user >~" somehow run it in a loop until the mailbox is sealed?
mroman 2017-02-21 08:36:55
mbrock: I just don't see a benefit of duck typed languages.
mroman 2017-02-21 08:37:00
except that you can hack around easier.
fizbin 2017-02-21 08:37:29
I wish there were an option for hp2ps to color the graph by a hash of the allocation point name, so that you could compare two graphs (of different versions of the program, or the behavior with different inputs) without mentally working out a color translation table.
mroman 2017-02-21 08:37:51
well... you can do more runtime hacking and runtime dependency things
mroman 2017-02-21 08:37:53
I give you that.
mbrock 2017-02-21 08:38:22
by some kind of meta-pragmatic philosophy I basically see their existence and popularity as proof that there are benefits. Identifying and formulating those benefits can be hard though
mbrock 2017-02-21 08:39:54
for example, David H. H. didn't make Rails in an ML-style language, and it might be interesting to think about why, if we concede that Rails has been quite a productive and useful thing
mbrock 2017-02-21 08:40:24
this might be too flamebaity or off-topic for #haskell though :)
mroman 2017-02-21 08:40:32
yep :)
sternmull 2017-02-21 08:41:00
srhb: Ah! Pipes documentation says "(draw >~ p) loops over p replacing each await with draw". So there it is. I probably should not assume that i could skip Pipes-tutorial and jump directly to Pipes.Concurrent without getting confused...
shapr 2017-02-21 08:42:02
sounds like a calm discussion so far
shapr 2017-02-21 08:42:40
I do wish I'd found Haskell earlier in my programming career.
Akii 2017-02-21 08:43:20
can I "embed" the failure type of one MonadError into a type of another MonadError?
mroman 2017-02-21 08:43:36
I found haskell at age 17 or something.
Akii 2017-02-21 08:43:39
(MonadError Text m1, MonadError (TextError err) m2) => m1 a -> m2 a
browndawg 2017-02-21 08:43:58
mbrock, rails is great for prototyping stuff, but then when you want some guarantees as to your code, you end up writing a huge test suite for it anyway
browndawg 2017-02-21 08:44:07
a lot of which is just compensating for the lack of static types
bollu 2017-02-21 08:44:32
mroman: same. mind was blown when I started learning.
Cale 2017-02-21 08:44:40
plantedseed: hey
browndawg 2017-02-21 08:44:44
Something like ruby / rails is great for getting work done initially with less overhead, which is useful when you might not know if your prototype will survive the week
bollu 2017-02-21 08:44:46
I still remember fondly someone showing me "fmap fmap fmap" :)
mroman 2017-02-21 08:44:46
I noticed that as soon as you handle user input you need to check the type.