Ferdirand 2017-01-26 21:46:06
also, be aware that when you are using ghci, what you enter is (roughly) in the context of a IO do-block, where actions can get executed immediately
Ferdirand 2017-01-26 21:46:18
this might be misleading
Bish 2017-01-26 21:46:20
i figured something like that
Bish 2017-01-26 21:48:42
so if i was about to write an echo server, i would write an action, which accepts connections, another one that multiplexes
Bish 2017-01-26 21:48:56
and would have purely function functions which use it's state to calculate an answer?
Bish 2017-01-26 21:50:55
is that correct?
uiop 2017-01-26 21:51:50
that's kind of vague Bish, it's hard to tell whether you've said something profound or said something confused :)
Ferdirand 2017-01-26 21:52:10
well there is a simpler example with no network involved
Ferdirand 2017-01-26 21:52:11
cat
Bish 2017-01-26 21:52:34
i always start with echo servers when learning a new language ;; how would io be different
Ferdirand 2017-01-26 21:52:58
fair enough
uiop 2017-01-26 21:53:16
Bish: exactly, it's *not* different. once you can code C in haskell, you've reached enlightenment
uiop 2017-01-26 21:53:20
.....or something
Ferdirand 2017-01-26 21:53:28
:t hGetLine
lambdabot 2017-01-26 21:53:30
error:
lambdabot 2017-01-26 21:53:30
• Variable not in scope: hGetLine
lambdabot 2017-01-26 21:53:30
• Perhaps you meant one of these:
Bish 2017-01-26 21:53:39
we can make it simplre though: if i have a "action" that just accepts socket, sends "hello" and closes.. what kind of function is that "action" then
Ferdirand 2017-01-26 21:54:25
it would not be a function, it would be a value
Bish 2017-01-26 21:54:39
i mean, it has sideeffects and probably "decides" what to do, maybe with exception handling, i don't know
Ferdirand 2017-01-26 21:54:45
unless you want to make it a function that accepts a port number to listen to
uiop 2017-01-26 21:54:51
Bish: there are so many abstraction levels stacked upon each other in haskell, it's impossible to answer that question without knowing at what level you desire an answer
Bish 2017-01-26 21:55:31
uiop: the most basic one
Ferdirand 2017-01-26 21:55:37
Bish: do you know the (>>), (>>=) operators yet ?
Bish 2017-01-26 21:55:57
i saw them in talks, they were described like pipes(abstract)
Bish 2017-01-26 21:56:13
but those are syntactical sugar, right? they get translated into something else
Ferdirand 2017-01-26 21:56:20
no, it's the opposite
uiop 2017-01-26 21:56:26
Bish: at the topmost level.... it's not a function unless the type is "...... -> IO (...)"
Ferdirand 2017-01-26 21:56:28
do-notation is sugar that translates into (>>=)
Bish 2017-01-26 21:56:46
oh, okay, i google the >>= operator
Ferdirand 2017-01-26 21:56:53
:t (>>=)
lambdabot 2017-01-26 21:56:55
Monad m => m a -> (a -> m b) -> m b
Ferdirand 2017-01-26 21:57:50
in the context of m being IO, it allows you to sequence two actions such that the definition of the second action depends on the result of the first
Ferdirand 2017-01-26 21:58:25
to be clear, (IO a) is the type of an action that, when run, yields a value of type a
Ferdirand 2017-01-26 21:59:24
there is no function (IO a -> a) in haskell, because knowing the definition of an action is not enough to know its result
Ferdirand 2017-01-26 21:59:28
for this you have to run it
Ferdirand 2017-01-26 21:59:51
and have effects on the world, etc
Ferdirand 2017-01-26 21:59:54
but what you can do
Ferdirand 2017-01-26 22:00:15
is use (>>=) :: (IO a) -> (a -> IO b) -> IO b
uiop 2017-01-26 22:01:17
:t unsafePerformIO
lambdabot 2017-01-26 22:01:19
error: Variable not in scope: unsafePerformIO
uiop 2017-01-26 22:01:30
liar
Ferdirand 2017-01-26 22:01:32
shhhh
Ferdirand 2017-01-26 22:01:38
that's a white lie
Ferdirand 2017-01-26 22:01:57
that means, if the second step of the computation (the function a -> IO b) needs to know the result a, before deciding what the next action will be
Ferdirand 2017-01-26 22:02:38
even though from haskell you cannot extract the a, you can use >>= to combine the actions so that the first part is run, then the second part is evaluated with the result and run
Ferdirand 2017-01-26 22:03:04
but this is still only combining actions; the actual running happens when this combined action itself is run
Bish 2017-01-26 22:04:14
i think i will just need to try it.. but syntax is haskell is very ugly too (imho)
Bish 2017-01-26 22:04:22
that's why i am hesitating
uiop 2017-01-26 22:05:43
Bish: it's like coffee, swedish fish, or crack cocaine. once you're hooked, it's too late
Ferdirand 2017-01-26 22:06:04
(>>=) is not very pretty indeed
uiop 2017-01-26 22:06:04
Bish: but srsly thogh, why do you say ugly?
Ferdirand 2017-01-26 22:06:08
that's why we have do-notation
Bish 2017-01-26 22:06:20
i tend not to glorify, especially fish, i wouldn't like fish
uiop 2017-01-26 22:06:25
heh
merijn 2017-01-26 22:06:31
I dunno, I kinda like >>=
Bish 2017-01-26 22:06:40
i always thought i've found the holy grail in programming
Ferdirand 2017-01-26 22:06:48
it's an acquired taste, maybe
Bish 2017-01-26 22:06:48
but i am pretty sure there is none
Bish 2017-01-26 22:07:02
Ferdirand: don't start this flamewar :D you can simply not like things
Bish 2017-01-26 22:07:10
there is no better taste, there is just taste
merijn 2017-01-26 22:07:21
Bish: That's why you learn haskell and start making your own programming languages!
Bish 2017-01-26 22:07:29
im a german, i went to japan, i tried, i tried really hard and got depressed, and that is nothing you learn
Bish 2017-01-26 22:07:36
(im talking about fish)
Ferdirand 2017-01-26 22:07:48
(i'm not saying it's better, i'm just saying taste evolves in time)
Bish 2017-01-26 22:08:00
that can also mean i hate fish more and more.
Bish 2017-01-26 22:09:35
when talking about ugly syntax i meant $ and .
Bish 2017-01-26 22:09:48
they're really making it worse (imho), why not just have prefix all the way
Bish 2017-01-26 22:09:56
but that is probably only opinion, too
Ferdirand 2017-01-26 22:09:59
then you get lisp
merijn 2017-01-26 22:10:02
That's not syntax, though
merijn 2017-01-26 22:10:17
THose are just functions, you could easily define your own prefix version
Bish 2017-01-26 22:10:18
merijn: i am not scientifical enough to understand that, but you get my point
Bish 2017-01-26 22:10:29
Ferdirand: so prefix haskell == lsip?
Bish 2017-01-26 22:10:55
merijn: if i always like to tell the compiler to use prefix yes.
Ferdirand 2017-01-26 22:11:49
no, but if you just dislike $ and ., you can entirely replace them with appropriate use of ()s
Ferdirand 2017-01-26 22:11:55
and lambdas
Ferdirand 2017-01-26 22:12:34
i kinda agree that $ looks very heavy for an application operator
Bish 2017-01-26 22:12:35
but what about things that are infix by defautl, say +
Profpatsch 2017-01-26 22:12:48
I want to write a DomT which is a ReaderT DomEnv m a
Bish 2017-01-26 22:12:49
i would have to do (+)(a,b)
Bish 2017-01-26 22:12:54
right?
Ferdirand 2017-01-26 22:12:59
(+) a b
Bish 2017-01-26 22:13:11
yeah that bugs me :/
Ferdirand 2017-01-26 22:13:17
or you could do plus = (+)
Bish 2017-01-26 22:13:18
always having to wrap it in ()
Ferdirand 2017-01-26 22:13:22
and then "plus a b"
Profpatsch 2017-01-26 22:13:23
Is there a nice way to inherit the instance from ReaderT?
merijn 2017-01-26 22:13:37
Profpatsch: Is DomT a newtype?
Profpatsch 2017-01-26 22:13:40
*instances
Profpatsch 2017-01-26 22:13:47
merijn: Yes, of course.
merijn 2017-01-26 22:14:02
Profpatsch: GeneralizedNewtypeDeriving
Profpatsch 2017-01-26 22:14:14
ReaderT has quite a few instances, I need to list them all, right?
Profpatsch 2017-01-26 22:14:49
And if ReaderT gets a new one, I'd have to update my library as well?
electrocat 2017-01-26 22:15:18
does anybody know how to specify that you want a man page when compiling ghc?
merijn 2017-01-26 22:15:18
Profpatsch: Yes
thatguy 2017-01-26 22:15:28
can anyone tell me why I get this error msg http://lpaste.net/351689 with this code http://lpaste.net/351688
merijn 2017-01-26 22:15:36
Profpatsch: If you care about that, why not directly expose the ReaderT?
thatguy 2017-01-26 22:15:37
for me I defined depth as Tree a -> Integer
thatguy 2017-01-26 22:15:42
I don't get why he is complaining
Profpatsch 2017-01-26 22:16:12
merijn: You mean just have a type instead of a newtype?
merijn 2017-01-26 22:16:40
Profpatsch: Or not even a type alias
merijn 2017-01-26 22:16:51
Profpatsch: Just have "ReaderT DomEnv m a" in your types
merijn 2017-01-26 22:17:10
I hate having to click through 5 type aliases to figure out something is just a ReaderT or whatever
electrocat 2017-01-26 22:17:57
thatguy: your are pattern matching on depthTree, it'l shadow the 'depthTree' function you created
shayan_ 2017-01-26 22:18:11
is there any channel to discuss databases?
thatguy 2017-01-26 22:18:22
electrocat, ah damn it! I used the same name twice
thatguy 2017-01-26 22:18:32
I should have seen that
thatguy 2017-01-26 22:18:35
electrocat, thanks a lot
electrocat 2017-01-26 22:19:05
thatguy: your are also doing 'depthTree newLeft + 1', this will probably produce an error aswel
thatguy 2017-01-26 22:19:38
electrocat, yes I had the same error over and over again
electrocat 2017-01-26 22:19:45
it should be 'depthTree (newLeft + 1)'
merijn 2017-01-26 22:19:46
thatguy: You'll probably wanna use -Wall when compiling
merijn 2017-01-26 22:19:55
thatguy: That will warn you if you shadow names
thatguy 2017-01-26 22:20:06
merijn, I only use ghci and :load
thatguy 2017-01-26 22:20:13
is there a -Wall flag there?
merijn 2017-01-26 22:20:31
thatguy: Pretty sure "ghci -Wall" works, not sure if it reports errors when using ":l" though
thatguy 2017-01-26 22:20:32
electrocat, no I actually want the depth of the newLeft tree and add one to it
electrocat 2017-01-26 22:20:39
i think you can do ':set -Wall' in ghci
Profpatsch 2017-01-26 22:20:44
merijn: or have a function that exposes the ReaderT Dom m a to the user if hir wants to use it?
merijn 2017-01-26 22:21:06
Profpatsch: Yes, but if you're going to expose the ReaderT what's the point of newtyping?
electrocat 2017-01-26 22:21:08
thatguy: my bad,
electrocat 2017-01-26 22:21:13
thatguy: nvm then :p
merijn 2017-01-26 22:21:24
Profpatsch: I mean, the entire reason people use newtypes is to *not* expose the underlying monad
Profpatsch 2017-01-26 22:21:31
Hm
merijn 2017-01-26 22:21:33
If that's not what you want, why bother?
Profpatsch 2017-01-26 22:21:38
Yeah, rigth.
merijn 2017-01-26 22:21:48
That's just giving other people busy work for no reason
uiop 2017-01-26 22:22:19
shayan_: what does that mean to discuss databases?
uiop 2017-01-26 22:22:27
shayan_: what aspect of them?
oeoeoeoe 2017-01-26 22:23:11
how I can make stack to use many cores?
Profpatsch 2017-01-26 22:23:28
merijn: On the other hand of course the interface breaks if I e.g. change the amount of fields in DomEnv
uiop 2017-01-26 22:23:54
what is this stack everyopne speaks of? forgive me, i'm a total newschool noob....
uiop 2017-01-26 22:24:07
ignore the fact i could google this
uiop 2017-01-26 22:24:14
ive had too many scotches...
shayan_ 2017-01-26 22:24:24
uiop: I'm seeking a real-time database that covers news and events
uiop 2017-01-26 22:24:58
shayan_: ok. do you want to consume a product that has already solved this problem, or do you seek to implement such a beast?
uiop 2017-01-26 22:25:53
shayan_: second level question being.... what does "realtime" mean, and what does "news and events" mean?
Profpatsch 2017-01-26 22:25:53
Why arest thou speaking in ancient tongues?
uiop 2017-01-26 22:26:06
Profpatsch: lol
merijn 2017-01-26 22:26:16
Profpatsch: If you expose the ReaderT in anyway your interface breaks *anyway*
Profpatsch 2017-01-26 22:26:28
merijn: You are right.
merijn 2017-01-26 22:26:29
Profpatsch: Since part of the API breaks if you change it
shayan_ 2017-01-26 22:26:38
uiop: I'm seeking to implement such a beast!
oeoeoeoe 2017-01-26 22:26:47
uiop: stack is like cabal, a kind of "make" for haskell
shayan_ 2017-01-26 22:26:50
uiop: As well as to consume, both really.
Profpatsch 2017-01-26 22:26:53
I probably don't need a transformer, I'll just do a simple stack.
quchen 2017-01-26 22:27:09
Profpatsch: The guy who asked about the good use of Cont in practice, do you know his name? I meant to tell him about chaining bracket/async and using Managed, but didn't have the time
Profpatsch 2017-01-26 22:27:11
And if the user wants to he'd have to run it and use that.
thatguy 2017-01-26 22:27:16
I am following the CIS 194 course for haskell (spring 2013) and there is a task to create a balanced binary tree (i.e. the depth of the left and right subtree only differ by one). If anyone would be so kind to look at my solution and give tips what I could have done better I would be very happy http://lpaste.net/351688
Profpatsch 2017-01-26 22:27:33
quchen: Markarius
uiop 2017-01-26 22:27:38
oeoeoeoe: i thanketh thouth for pitying those that the suneth doth hast noteth shine upon in the recent
quchen 2017-01-26 22:27:56
Profpatsch: markarius@ihatesmlnj.com? ;-)
Profpatsch 2017-01-26 22:28:09
hahah
Profpatsch 2017-01-26 22:28:18
quchen: Just put it on the curry-club ml
Profpatsch 2017-01-26 22:28:28
This way everyone can read it.
Profpatsch 2017-01-26 22:28:52
curry-talk@lists.openlab-augsburg.de
Profpatsch 2017-01-26 22:29:05
If you don't want to sub I can leave it through.
uiop 2017-01-26 22:29:10
shayan_: ok, sik! so what does realtime mean? (rhetorical)
uiop 2017-01-26 22:30:15
shayan_: well, that's an "actual" question really.... the real relevant question is: what are your goals, and what are your constraints
quchen 2017-01-26 22:30:52
Profpatsch: »Sie dürfen nicht abonnieren weil die von Ihnen angegebene E-Mail-Adresse als unsicher betrachtet wird.«
quchen 2017-01-26 22:30:55
Guess not.
uiop 2017-01-26 22:31:31
shayan_: ok, all bullshit aside (remember i'm, drinking scotch..): what is the application?
Profpatsch 2017-01-26 22:32:51
quchen: The guy is the maintainer of Isabelle btw, and longer in the business than any of us combined. >.
shayan_ 2017-01-26 22:33:24
uiop: my goal is to find out more on the GDELT Project. Do you know anything about it?
quchen 2017-01-26 22:34:20
Oh! Then I guess I can find his mail elsewhere ;-)
uiop 2017-01-26 22:34:49
shayan_: i do not know about that project, but now i'm curious. do you have a link?
shayan_ 2017-01-26 22:35:32
http://www.gdeltproject.org/
uiop 2017-01-26 22:36:33
shayan_: thx
uiop 2017-01-26 22:37:09
nice animated gif
Omnic 2017-01-26 22:37:20
question, with foldl (+) 0 [1..10], how does (b -> a -> b) translate to the (+) portion
Omnic 2017-01-26 22:37:29
(in the type of foldl, when you do :t foldl)
oeoeoeoe 2017-01-26 22:37:40
i'm looking at the docs about how to compile in parallel with stack but I see nothing, unlike cabal
merijn 2017-01-26 22:38:47
Omnic: Well, remember that 'b -> a -> b' means that 'a' and 'b' *can* be different, they don't *have* to be
merijn 2017-01-26 22:39:17
Omnic: So if we simplify '(+) :: Int -> Int -> Int' and compare that with 'b -> a -> b' we just get 'a = Int' and 'b = Int'
merijn 2017-01-26 22:39:45
:t Data.List.foldl
lambdabot 2017-01-26 22:39:47
Foldable t => (b -> a -> b) -> b -> t a -> b
Omnic 2017-01-26 22:39:56
alright that makes sense
merijn 2017-01-26 22:40:42
and then we simply replace all the other 'a' and 'b' with Int
Omnic 2017-01-26 22:40:49
so (b -> a -> b) is a function in the type declaration?
merijn 2017-01-26 22:41:08
Omnic: Yes
Omnic 2017-01-26 22:41:14
alright thanks
merijn 2017-01-26 22:41:47
Omnic: Specifically a function that takes an 'b' and 'a' and returns a 'b', for whatever types of 'a' and 'b' we want :)
Omnic 2017-01-26 22:42:14
mucking about in haskell doing projecteuler
Omnic 2017-01-26 22:42:29
i came from scala, i do that purely functional, figure i might as well give haskell a shotr
uiop 2017-01-26 22:42:37
:t [unsafeCoerce, id]
lambdabot 2017-01-26 22:42:39
error:
lambdabot 2017-01-26 22:42:39
Variable not in scope: unsafeCoerce :: a -> a
merijn 2017-01-26 22:42:56
Word of warning, I think Project Euler is...not great, in terms of programming excersises, especially not for Haskell
Ferdirand 2017-01-26 22:43:26
merijn: why that ?
Omnic 2017-01-26 22:43:28
question 2 was good to teach me infinite lists w/ the fibonacci sequence
merijn 2017-01-26 22:43:42
It's fun if you like number theory, but the exercises focus on things that are not common programming tasks
Kristof_HT 2017-01-26 22:43:55
i enjoy project Euler, but didn't try it in haskell yet
Ferdirand 2017-01-26 22:44:08
thanks FSM there is Math.NumberTheory
Omnic 2017-01-26 22:44:14
merijn: true
merijn 2017-01-26 22:44:25
Additionally, the numeric hierarchy is one of the less nice portions of Haskell in my (and many other people's opinion) and PE really grinds your face into it
uiop 2017-01-26 22:44:27
wow there is so much i need to catch up on