lookup 2017-02-21 19:45:13
Hi
johnw 2017-02-21 19:45:14
the return type is the domain
johnw 2017-02-21 19:45:25
or am I up too late?
mrkgnao 2017-02-21 19:45:26
threshold: I meant my nick, haha
johnw 2017-02-21 19:45:43
sorry, co-domain is good
mrkgnao 2017-02-21 19:45:54
I spoke too soon, though. I'm trying to write (>>=) without looking.
threshold 2017-02-21 19:45:59
johnw: So it is confusing :)
johnw 2017-02-21 19:46:13
not having started out as a mathematician, I still get them confused
Koterpillar 2017-02-21 19:46:23
mrkgnao: for which type?
threshold 2017-02-21 19:46:57
johnw: I do too, but it would be nice to use these terms
johnw 2017-02-21 19:47:31
not two seconds ago I just edited a variable named "cod" that represented the return type of a function, so yes, it is too late
johnw 2017-02-21 19:47:32
good night :)
threshold 2017-02-21 19:49:57
johnw: I can't think of a term for the elements in the domain. Using spatial ordinal numbers plus the term "parameter" seems to be understandable by everyone, e.g. "This function takes two parameters, the first parameter is a list of Ints, the second parameter is a function, and the return type is also a list of Ints"
threshold 2017-02-21 19:50:30
johnw: Oh, sorry. I didn't realize you were going to bed. Thanks for your input!
Cooler 2017-02-21 19:53:40
when you have m a >>= (a -> m b) does m a get evaluated to weak head normal form so that >>= can pattern match?
threshold 2017-02-21 19:54:46
Cooler: That seems like a good guess
athan 2017-02-21 19:54:48
Cooler: Iff >>= is defined s.t. it needs the pattern match
athan 2017-02-21 19:54:59
the pattern-match induces the evaluation level
threshold 2017-02-21 19:55:01
s.t.?
Cooler 2017-02-21 19:55:05
right
kadoban 2017-02-21 19:55:08
such that
athan 2017-02-21 19:55:14
much wow
Cooler 2017-02-21 19:55:47
so what about IO a?
athan 2017-02-21 19:55:54
Cooler: So for the Identity monad, it only evaluates the Identity data constructor, because that's all that's matched
athan 2017-02-21 19:56:02
for Maybe, it could be Just or Nothing
Cooler 2017-02-21 19:56:30
are there patterns to match for IO a?
athan 2017-02-21 19:56:34
IO is tricky - it doesn't have a data representation (someone might call me out on this C:)
phadej 2017-02-21 19:56:40
Cooler: there are
ReinH 2017-02-21 19:56:53
it has one, but it's basically a lie
phadej 2017-02-21 19:57:13
the RealWorld# is a lie, but the IO as a state monad isn't :)
threshold 2017-02-21 19:57:17
> pure 3 :: IO Int
lambdabot 2017-02-21 19:57:19
ReinH 2017-02-21 19:57:30
phadej: unless you think the state contains something that isn't a lie
threshold 2017-02-21 19:58:01
> let x = pure 3 :: IO Int in case x of IO 3 -> putStrLn "3 detected"
lambdabot 2017-02-21 19:58:04
error:
lambdabot 2017-02-21 19:58:04
Not in scope: data constructor 'IO'
lambdabot 2017-02-21 19:58:04
Perhaps you meant 'In' (imported from Lambdabot.Plugin.Haskell.Eval.Trus...
threshold 2017-02-21 19:58:12
> let x = pure 3 :: IO Int in case x of IO 3 -> print "3 detected"
lambdabot 2017-02-21 19:58:14
error:
lambdabot 2017-02-21 19:58:14
Not in scope: data constructor 'IO'
lambdabot 2017-02-21 19:58:14
Perhaps you meant 'In' (imported from Lambdabot.Plugin.Haskell.Eval.Trus...
phadej 2017-02-21 19:58:18
(also IO uses unlifted tuple, so the `a` in IO a is forced to whnf in binds)
threshold 2017-02-21 19:58:27
lambdabot: What do you have in scope? :)
ReinH 2017-02-21 19:58:45
well, it doesn't have a nonexistent constructor in scope.
threshold 2017-02-21 19:58:51
:)
phadej 2017-02-21 19:58:56
the constructor is there: https://www.stackage.org/haddock/lts-8.2/ghc-prim-0.5.0.0/src/GHC-Types.html#IO
threshold 2017-02-21 19:58:59
I see that it fails in ghci as well
phadej 2017-02-21 19:59:05
import GHC.Types
ReinH 2017-02-21 19:59:14
ghc-prim is a lie
phadej 2017-02-21 19:59:25
~an implementation detail
ReinH 2017-02-21 20:00:59
the implementation is... I think you get my point.
lpaste_ 2017-02-21 20:01:20
threshold pasted "Attempt to pattern match on IO 3" at http://lpaste.net/352865
athan 2017-02-21 20:01:35
RealWorld# can't melt State beams
phadej 2017-02-21 20:01:38
well, if we had linear types, we could safely export IO constructor (and only keep RealWorld abstract)
mrkgnao 2017-02-21 20:03:26
Koterpillar (for when you come back): the Free monad on a functor
Cooler 2017-02-21 20:04:06
so does that mean you can't pattern match on IO?
phadej 2017-02-21 20:04:21
you can, but you don't need to
phadej 2017-02-21 20:04:48
(you'll get it wrong few first times anyway)
threshold 2017-02-21 20:06:01
As exemplified by my first attempt
Cooler 2017-02-21 20:06:54
how does the Monad instance of IO pattern match in the definition of >>=
Cooler 2017-02-21 20:06:56
?
phadej 2017-02-21 20:08:22
https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#bindIO
threshold 2017-02-21 20:09:10
phadej: It might be useful to know how to pattern match on IO, but I don' think I could figure it out tonight
athan 2017-02-21 20:09:22
oh woah I didn't know it was single threaded
athan 2017-02-21 20:09:27
is that how ST works too?
fProgrammer 2017-02-21 20:09:30
quick question: I'm trying to use a haskell library (https://github.com/haskell-works/kafka-client/) and this is my stack.yml(http://lpaste.net/5184215642999357440). It builds fine, but I get warning from stack: "This is usually a mistake, external packages should typically be treated as extra-deps to avoid spurious test case failures." what does this mean and how do I solve it?
athan 2017-02-21 20:10:20
fProgrammer: There's an `extra-dep: true` field you should use under the `packages:` section in your stack.yaml
Cooler 2017-02-21 20:10:21
well thats weird, they pretend like IO has a data constructor IO
threshold 2017-02-21 20:10:33
Is Template Haskell necessary to pattern match on IO?
phadej 2017-02-21 20:10:45
threshold: there is no template haskell
athan 2017-02-21 20:10:54
something like `packages:\n - foo:\ git: blahblahblah\n commit: !@$#\n extra-dep:true` or something
phadej 2017-02-21 20:11:03
threshold: there is UnboxedTuples
threshold 2017-02-21 20:11:15
phadej: (# new_s, a #) the (# and #) symbols represent unboxed tuples?
phadej 2017-02-21 20:11:18
yes
fProgrammer 2017-02-21 20:11:48
athan: Tried adding "- extra-dep: true" under "packages:" but it fails parsing stack.yaml: Error in $.packages[0]: failed to parse field 'packages': failed to parse field 'location': key "location" not present
phadej 2017-02-21 20:11:52
which are ~ StrictPair a b = SP !a !b
athan 2017-02-21 20:12:03
fProgrammer: It's a subfield for items in that list
athan 2017-02-21 20:12:13
not an item itself
phadej 2017-02-21 20:12:13
not 100% sure if those are the same, close enough
Cooler 2017-02-21 20:13:06
how does this work? bindIO (IO m) k = IO (\ s -> case m s of (# new_s, a #) -> unIO (k a) new_s)
Cooler 2017-02-21 20:13:18
can't pattern match on IO m
athan 2017-02-21 20:13:39
fProgrammer: Here's an example: https://github.com/moneybit/moneybit/blob/master/stack.yaml#L42
threshold 2017-02-21 20:14:04
phadej: Thank you for the explanation. I don't know how important it is for me to dive into boxed and unboxed types today. It does sound intriguing though
fProgrammer 2017-02-21 20:15:03
athan: Tried this snippet: http://lpaste.net/5820708218350862336 I get following error "Error parsing targets: The project contains no local packages (packages not marked with 'extra-dep')"
fProgrammer 2017-02-21 20:15:31
sorry, I realize it's something v trial but I can't seem to get it right
threshold 2017-02-21 20:15:44
athan: Why is it surprising that it is single threaded? I'm new, but I thought that it was linear/sequential and if you needed parallelism or concurrency, there are functions available.
athan 2017-02-21 20:15:47
np, I've been there more than I'll admit :)
athan 2017-02-21 20:15:59
threshold: eh idk lol
threshold 2017-02-21 20:16:04
I do not know why I pointed out that I'm new
athan 2017-02-21 20:16:09
it just feels more like StateT than ST
athan 2017-02-21 20:16:23
(I don't know how ST works though v.v)
kadoban 2017-02-21 20:16:41
fProgrammer: add the line - '.' after "packages:" most likely
threshold 2017-02-21 20:17:14
athan: I haven't messed with monad transformers yet. I'm guessing it will be a bumpy ride
athan 2017-02-21 20:17:17
I think it just needs an indent :x
phadej 2017-02-21 20:17:18
athan: ST, IO and State are all variations on the same: https://www.stackage.org/haddock/lts-8.2/base-4.9.1.0/src/GHC-ST.html#ST
athan 2017-02-21 20:17:31
threshold: It's actually a lot of fun :) just higher-order monads
athan 2017-02-21 20:17:37
:O
athan 2017-02-21 20:17:41
thanks phadej
fProgrammer 2017-02-21 20:17:58
kadoban: Yeah, it worked! Thanks! But now I am confused, why do I have to add "." i.e. a root directory?
athan 2017-02-21 20:18:10
fProgrammer: try indenting lines 2-5
Cooler 2017-02-21 20:18:15
anyone?
phadej 2017-02-21 20:18:18
athan: there is a special op in IO: fork# which let you tell the run-time-system "evaluate that part in parallel as well"
threshold 2017-02-21 20:18:18
athan: I struggle with knowing how to move values between monads. I've only started bumping into lift and liftIO
kadoban 2017-02-21 20:18:38
Well, it's presumably supposed to be building something with this package, right? You have to tell it where that is. Usually it's just "the current directory" aka '.'
kadoban 2017-02-21 20:18:55
extra-dep ones just tell it what stuff you want to use as a dependency, essentially.
phadej 2017-02-21 20:18:55
athan: you might look into https://www.youtube.com/watch?v=-MFk7PIKYsg
athan 2017-02-21 20:19:14
phadej: ahhhh that's how they do it :)
athan 2017-02-21 20:19:30
threshold: That's monad transformers :D
phadej 2017-02-21 20:19:34
which explains how haskell is evaluated, the threads are just having two simultaneous evaluators (IIRC it's briefly mentioned in the talk)
phadej 2017-02-21 20:20:14
athan: it's all not so complicated, you just have to click "source" in haddocks
athan 2017-02-21 20:20:18
oh sweet, I need to know more STG
athan 2017-02-21 20:20:33
yeah, but... gossip is so much easier :D
athan 2017-02-21 20:20:37
thanks phadej
phadej 2017-02-21 20:20:39
np
fProgrammer 2017-02-21 20:21:10
athan: Thanks, I added "." and it worked, unsure why ¯\_(ツ)_/¯
athan 2017-02-21 20:21:35
fProgrammer: hmm, I think it needs a target package or something, not just deps x_x
kadoban 2017-02-21 20:23:45
Ya, it does.
lpaste_ 2017-02-21 20:25:15
threshold pasted "Monad Transformer Talk" at http://lpaste.net/352866
threshold 2017-02-21 20:25:52
If I set the return value to be "pure id" then it compiles successfully.
threshold 2017-02-21 20:26:53
Is it possible to not use "pure id" and take the Maybe value and lift it into the monad used by Scotty?
threshold 2017-02-21 20:27:25
maybe that is what lift does :)
Cale 2017-02-21 20:27:56
threshold: What are you trying to do?
threshold 2017-02-21 20:28:49
Cale: I am simply looking to refactor
Cale 2017-02-21 20:29:15
Perhaps you meant to write return id
threshold 2017-02-21 20:29:34
Cale: pure id and return id both work
Cale 2017-02-21 20:29:47
Yeah, because you need an IO action there.
Cale 2017-02-21 20:34:30
But yeah, if you change it to createUser email = liftIO $ do
Cale 2017-02-21 20:34:57
you can change the type to createUser :: (MonadIO m) => T.Text -> m (Maybe [T.Text])
Cale 2017-02-21 20:35:20
and then you won't need the liftIO in main
Cale 2017-02-21 20:35:58
Also, you might find it more comfortable to add a line: import Data.Text (Text) so that you can write Text in the types rather than T.Text
threshold 2017-02-21 20:42:53
I don't understand why the line "result <- lift $ createUser email" has an expected type of Web.Scotty.Internal.Types.ActionT L.Text IO [T.Text]