Tuplanolla 2017-02-26 05:45:57
Is it a better idea to use `type` or `newtype` for monad stacks? Is this discussed somewhere?
monochrom 2017-02-26 05:46:55
It is discussed all the time here. Go with newtype in the long run.
glguy 2017-02-26 05:47:00
I prefer newtype
Welkin 2017-02-26 05:47:17
type is only useful for simple types that you want to alias for easier reading
EvanR 2017-02-26 05:47:19
when you are implementing some API with a transformer stack, it clearly needs to be a newtype
Welkin 2017-02-26 05:47:28
like `type Deck = [Card]`
sm 2017-02-26 05:47:30
kgadek: markdown, sundown, commonmark maybe
Tuplanolla 2017-02-26 05:47:30
Okay. How do they interact with mtl style?
kgadek 2017-02-26 05:47:52
sm: thanks!
glguy 2017-02-26 05:47:54
you can use the mtl classes to help you implement your actual operations
sm 2017-02-26 05:48:08
cmark, not commonmark. A search for markdown will tell you
bollu 2017-02-26 05:48:24
type TcRnIf a b = IOEnv (Env a b)
Tuplanolla 2017-02-26 05:48:28
Very well.
bollu 2017-02-26 05:48:28
how does that typecheck?
bollu 2017-02-26 05:48:33
doesn't IOEnv need two parameters?
monochrom 2017-02-26 05:48:40
"type" is more convenient for the author. "newtype" is a bit more work for the author. However, "type"'s convenience for the author tends to become leaky abstraction. You won't want leaky abstraction for serious code.
jberges 2017-02-26 05:48:58
@pl \ps -> (map (\(a:b:c:[]) -> a + b + c) [ drop (i - 3) $ take i ps | i<-[3..length ps]])
lambdabot 2017-02-26 05:48:58
(line 1, column 22):
lambdabot 2017-02-26 05:48:58
unexpected "["
lambdabot 2017-02-26 05:48:58
expecting "()", natural, identifier, "_" or "("
maerwald 2017-02-26 05:49:09
newtype is also (useless) work for API users sometimes
heartbreakers 2017-02-26 05:49:30
:)
EvanR 2017-02-26 05:50:38
the api users arent supposed to know how you implemented it
bollu 2017-02-26 05:50:41
newtype IOEnv env a = IOEnv (env -> IO a); type TcRnIf a b = IOEnv (Env a b); how is the TcRnlf declaration correct? doesn't IOEnv need two types "a" and "b"?
monochrom 2017-02-26 05:51:59
Yes, but they are sometimes called "env" and "a".
monochrom 2017-02-26 05:52:38
Ah so this means "TcRIf X Y" still has kind * -> *
heartbreakers 2017-02-26 05:52:53
A for administration
bollu 2017-02-26 05:53:33
monochrom: yeah, looks like it's curried. I didn't know you could curry newtypes :)
lassulus 2017-02-26 06:33:29
I'm confused by the target group of this spam approach
sternmull 2017-02-26 06:33:59
i want to update a bunch of fields conditionally. For each field i have a predicate and a value that should be applied when the predicate is True. What is a nice way to do that?
Welkin 2017-02-26 06:34:24
sternmull: you could put that all inside of a function
Welkin 2017-02-26 06:34:29
or perhaps there is something in lens for that