threshold 2017-02-21 20:46:16
Cale: I don't know if you were around earlier, but it was working. This is me refactoring to make the types of createUser a little nicer
threshold 2017-02-21 20:46:37
Ultimately, I think it would be nice to return a User as suggested by Koterpillar
maybefbi 2017-02-21 21:00:33
is it true that ever since Applicative became the superset of Monad in Haskell, GeneralizedNewtypeDeriving of application monads need to say deriving (...., Applicative, Functor) also?
cocreature 2017-02-21 21:01:19
maybefbi: I'm tempted to say yes, but I don't know what you are referring to by "application monad"
maybefbi 2017-02-21 21:02:07
By application monad I mean how we invente newtype App a = App { ... } deriving (....) for our app
cocreature 2017-02-21 21:02:22
oh I was thinking of function application :)
maybefbi 2017-02-21 21:02:36
did i use the wrong name?
cocreature 2017-02-21 21:02:52
I don't think so. "application" is just an overloaded name
maybefbi 2017-02-21 21:02:58
yeah
cocreature 2017-02-21 21:03:13
maybefbi: you definitely need the Applicative and the Functor instance. whether you get them via GND or write them manually doesn't matter
maybefbi 2017-02-21 21:04:08
thanks a lot
maybefbi 2017-02-21 21:04:14
i did not know this
maybefbi 2017-02-21 21:04:29
even old textbooks like real world haskell dont say this
maybefbi 2017-02-21 21:04:49
they only preach to GND until Monad, inside your stack
cocreature 2017-02-21 21:04:50
real world haskell was written before Applicative became a superclass of Monad :)
maybefbi 2017-02-21 21:04:58
:D yeah makes sense
tfc[m] 2017-02-21 21:10:31
i always thought that applicative is a subclass of monad, because monad can do more.
cocreature 2017-02-21 21:11:12
tfc[m]: every Monad is an Applicative, so Applicative is more general ⇒ Applicative is a superclass of Monad
cocreature 2017-02-21 21:18:14
tfc[m]: that doesn't matter
sshine 2017-02-21 21:18:39
tfc[m], I'm assuming you mean something like 'do { a <- foo; b <- bar a; return $ Constructor a b }'
tfc[m] 2017-02-21 21:19:10
sshine: maybe that is a better example than what i provided.
ongy 2017-02-21 21:19:23
ohh, for the second one. What was it that monads give us? That we can decide controll flow? so do { x<- foo; if x then bar else baar }
Freundlich 2017-02-21 21:19:24
I had similar thoughts about subtyping, where you denote "a is a subtype of b" by "a <: b" and you also say "a is smaller than b". Here, a actually has "more elements" than b, but the thing is that a has fewer instances, therefore it's considered "smaller" or "more specialized".
tfc[m] 2017-02-21 21:19:27
cocreature: " making an instance of Applicative requires less than making something an instance of Monad, so in that sense Applicative is more general." ok, that sounds really plausible
bollu 2017-02-21 21:21:39
tfc[m]: one way to look at it is, given Monad m, I can _always_ implement Applicative m
tfc[m] 2017-02-21 21:23:45
bollu how about the following parser example: how do you do something like the following in applicative style: parser = do { bytes <- read $ word; payload <- readbytes bytes; return payload }
jle` 2017-02-21 21:27:47
@undo do { bytes <- read $ word; payload <- readbytes bytes; return payload }
lambdabot 2017-02-21 21:27:48
read $ word >>= \ bytes -> readbytes bytes >>= \ payload -> return payload
tfc[m] 2017-02-21 21:27:54
i am often writing unnecessarily complex lines.
jle` 2017-02-21 21:27:54
oops
jle` 2017-02-21 21:28:07
tfc[m]: well, the desugarer won't help you here
jle` 2017-02-21 21:28:22
the desugared version is probably even less readable than the do notation version
ongy 2017-02-21 21:28:32
hlint can find some of those I think
tfc[m] 2017-02-21 21:28:35
ok
jle` 2017-02-21 21:29:07
stuff like this is more similar to seeing that x * 1 = x
jle` 2017-02-21 21:29:13
so instead of writing 'x * 1', you can just write 'x'
jle` 2017-02-21 21:29:50
so it's not a desugaring issue; it's a...refactoring issue?
zipper 2017-02-21 21:37:28
mniip: How so?
zipper 2017-02-21 21:37:41
Well the quality and nature of practice
zipper 2017-02-21 21:37:52
Like what specifically should one aim for?
mniip 2017-02-21 21:37:55
I like to reimplement studd on my own
mniip 2017-02-21 21:37:58
stuff
zipper 2017-02-21 21:38:25
Self teaching seems to be the slowest way to learn :( by the time one is good they'll be old :(
mniip 2017-02-21 21:38:37
I disagree
zipper 2017-02-21 21:38:41
mniip: Libs or algos?
mniip 2017-02-21 21:38:41
it pays off in the end
zipper 2017-02-21 21:38:52
mniip: Please explain
mniip 2017-02-21 21:39:06
zipper, well, not like whole libs
zipper 2017-02-21 21:39:20
mniip: Why do you say it pays off in the end?
mniip 2017-02-21 21:39:26
but maybe, protocols, or structures that are already implemented in some lib
mniip 2017-02-21 21:39:30
just to see if I can
zipper 2017-02-21 21:39:33
I see
mniip 2017-02-21 21:39:45
zipper, when you self-teach you learn to self-teach really well
mniip 2017-02-21 21:40:00
and you can pick up stuff on your own very quickly
mniip 2017-02-21 21:40:27
and you don't depend on another person preparing the information for you
ongy 2017-02-21 21:40:53
then I noticed that DNS is weird
mniip 2017-02-21 21:41:30
I think a particular subset of like-minded people are OS hobbyists
zipper 2017-02-21 21:42:02
mniip: Well you know in the end when you are say interviewing what matters is, do you or don't you know.
mniip 2017-02-21 21:42:08
writing OSes with code that is analogous to already existing code just to 1) see if they can 2) better understand it 3) find out it's really weird
zipper 2017-02-21 21:42:12
Not can you self teach and such, right?
mniip 2017-02-21 21:42:46
zipper, depends on the interviewer