bollu 2017-02-19 02:45:09
or skimming the docs?
chrisIrcTheFirst 2017-02-19 02:45:16
I don't agree with the error message, could anyone explain why I'm getting that error message?
lyxia 2017-02-19 02:45:23
bollu: skimming the docs
bollu 2017-02-19 02:45:23
chrisIrcTheFirst: can you post the code on lpaste.net
bollu 2017-02-19 02:45:23
?
bollu 2017-02-19 02:45:28
lyxia: I see
bollu 2017-02-19 02:45:47
lyxia: I don't understand the type magic in lens very well (how prisms can "correctly" decay to traversals, etc)
bollu 2017-02-19 02:45:54
lyxia: I'm hoping it will make sense with repeated use
chrisIrcTheFirst 2017-02-19 02:46:23
http://lpaste.net/352713 - can anyone help me understand this error message?
chrisIrcTheFirst 2017-02-19 02:46:56
As far as I can understand both `a` and `Data.Text.Internal.Lazy.Text` are type variables?
lyxia 2017-02-19 02:47:08
chrisIrcTheFirst: a is a type variable (starts with a lowercase)
lyxia 2017-02-19 02:47:15
chrisIrcTheFirst: Text is a type constructor
dramforever 2017-02-19 02:47:19
Data.Text.Internal.Lazy.Text is a concrete type
dramforever 2017-02-19 02:47:43
(ConvertibleStrings a Data.Text.Internal.Lazy.Text) as a constraint is not normally allowed in Haskell. 'Use FlexibleContexts to permit this'
dramforever 2017-02-19 02:48:00
To do this, put {-# LANGUAGE FlexibleContexts #-} at the top of your file
chrisIrcTheFirst 2017-02-19 02:48:27
a is a concrete type too though? Isn't it?
geekosaur 2017-02-19 02:48:51
no, it's a variable
dramforever 2017-02-19 02:50:08
chrisIrcTheFirst: You can substitute some concrete type in for a
geekosaur 2017-02-19 02:50:12
"a" is a marker for a type that must be inferred from use (or specified explicitly with a type ascription (e.g. `(value :: Int)`)
dramforever 2017-02-19 02:50:14
but you cannot do so for Text
geekosaur 2017-02-19 02:50:33
Text is a concrete type; it can't be inferred, it is explicit, uses can't alter it
lpaste_ 2017-02-19 02:51:36
lyxia annotated "No title" with "to osa1 (annotation)" at http://lpaste.net/352712#a352714
lyxia 2017-02-19 02:51:46
osa1: I changed just the instances
osa1 2017-02-19 02:52:27
lyxia: it doesn't fix the problem though
chrisIrcTheFirst 2017-02-19 02:52:27
geekosaur, dramforever - Thank you. Guess I have some reading to do!
lyxia 2017-02-19 02:53:08
osa1: what is the problem?
osa1 2017-02-19 02:53:19
lyxia: overlapping instances when last line is enabled
osa1 2017-02-19 02:53:31
this only depends on base try it
lyxia 2017-02-19 02:53:42
osa1: that's what I meant to fix, and it compiles fine.
osa1 2017-02-19 02:53:47
huh
osa1 2017-02-19 02:54:07
oh sorry, one sec
osa1 2017-02-19 02:54:53
thanks lyxia
lyxia 2017-02-19 02:55:02
yw
bollu 2017-02-19 02:55:20
what are the collection of things that can be "review"wed?
bollu 2017-02-19 02:55:26
only Prisms?
dramforever 2017-02-19 02:56:13
How would you convince one that the benefits of non-strict semantics outweigh the performance uncertainty and penalty?
lyxia 2017-02-19 02:56:21
bollu: "Review"
bollu 2017-02-19 02:56:35
lyxia: yes, so, like, what all can Review "match" with"
bollu 2017-02-19 02:56:40
lyxia: the types are somewhat.. dense
lyxia 2017-02-19 02:58:56
The docs mention Iso and Prism, and I guess the list is exhaustive for the "standard" optics.
bollu 2017-02-19 02:59:06
I see, thank you
bollu 2017-02-19 02:59:13
lyxia: Iso captures isomorphism?
lyxia 2017-02-19 02:59:34
yeah
bollu 2017-02-19 03:03:20
is there an idiomatic lensy way to write f (o ^. lens1 . lens 2 . lens3) ?
bollu 2017-02-19 03:03:36
some way to avoid the awkward "f" that is "outside"?
bollu 2017-02-19 03:03:50
o ^. lens1 . lens 2 . lens3 & f would work?
lyxia 2017-02-19 03:04:24
:t ?f (o ^. ?l)
lambdabot 2017-02-19 03:04:26
(?l::Getting t Expr t, ?f::t -> t1) => t1
dramforever 2017-02-19 03:04:34
'to' converts a function into a getter
lyxia 2017-02-19 03:04:37
:t (o ^. to ?f . ?l)
lambdabot 2017-02-19 03:04:39
(?l::(a -> Const a a) -> a1 -> Const a a1, ?f::Expr -> a1) => a
bollu 2017-02-19 03:04:59
lyxia: is the order not wrong?
lyxia 2017-02-19 03:05:03
I may have gotten it wrong
lyxia 2017-02-19 03:05:08
:t (o ^. ?l . to ?f)
lambdabot 2017-02-19 03:05:10
(?l::(s -> Const a s) -> Expr -> Const a Expr, ?f::s -> a) => a
bollu 2017-02-19 03:05:27
yeah
bollu 2017-02-19 03:05:29
hm
lyxia 2017-02-19 03:05:37
is this implicit param thing readable?
bollu 2017-02-19 03:05:43
:t to
lambdabot 2017-02-19 03:05:46
(Contravariant f, Profunctor p) => (s -> a) -> Optic' p f s a
lyxia 2017-02-19 03:05:47
:t \ f l -> (o ^. l . to f)
lambdabot 2017-02-19 03:05:50
(s -> a) -> ((s -> Const a s) -> Expr -> Const a Expr) -> a
bollu 2017-02-19 03:07:02
what is Optic' ?
delYsid 2017-02-19 03:07:31
Heh, I just used Haskell @ work for the first time ever, and it has turned out quite well. Just 200 lines of a Web API client. But it feels a lot more save then the previous Python version.
delYsid 2017-02-19 03:08:20
Thanks wreq and trifecta!
bollu 2017-02-19 03:09:01
> "woo" ^. (to (++ "hello"))
lambdabot 2017-02-19 03:09:05
"woohello"
bollu 2017-02-19 03:09:09
I'm sorry but that really hurts my brain
bollu 2017-02-19 03:09:28
so, like, a lens (an accessor) now provides you an "augmented" view of the original object?
bollu 2017-02-19 03:09:35
in a sense, I can create "fake" lenses?
bollu 2017-02-19 03:09:37
well
bollu 2017-02-19 03:09:39
not "fake"
lyxia 2017-02-19 03:09:46
bollu: types in lens have this shape: (a -> f b) -> s -> f t, Optic is the type synonym for this shape.
bollu 2017-02-19 03:09:46
but, like, "alternate reality lenses"?
delYsid 2017-02-19 03:09:50
(BTW, wreq is not in stackage it seems. What determines if a package needs to be put in extra-deps? wreq seems quite nice, so i wonder why it isn't there.)
bollu 2017-02-19 03:09:57
lyxia: but there is an extra p in the optic
lyxia 2017-02-19 03:10:05
bollu: yeah it generalizes a bit further
lyxia 2017-02-19 03:10:10
for prisms and isos
bollu 2017-02-19 03:10:22
> 1 ^. (to (\x -> if x > 10 then 10 else x))
lambdabot 2017-02-19 03:10:26
1
bollu 2017-02-19 03:10:35
> 20 ^. (to (\x -> if x > 10 then 10 else x))
lambdabot 2017-02-19 03:10:38
10
bollu 2017-02-19 03:10:44
oh my god that is _so cool_
lyxia 2017-02-19 03:10:52
then the whole library is about what happens when you make various constraints about f and p.
bollu 2017-02-19 03:11:10
I see
bollu 2017-02-19 03:11:15
lyxia: lens is so cool :D
bollu 2017-02-19 03:11:23
lyxia: how do I map with a lens?
bollu 2017-02-19 03:11:36
map (^. (to (\x -> if x > 10 then 10 else x))) [8…12]
bollu 2017-02-19 03:11:42
> map (^. (to (\x -> if x > 10 then 10 else x))) [8…12]
lambdabot 2017-02-19 03:11:45
error:
lambdabot 2017-02-19 03:11:45
Variable not in scope: … :: Integer -> Integer -> s
bollu 2017-02-19 03:11:48
thereuhh
bollu 2017-02-19 03:11:50
uh
bollu 2017-02-19 03:12:15
> map (^. (to (\x -> if x > 10 then 10 else x))) [8..12]
lambdabot 2017-02-19 03:12:18
[8,9,10,10,10]
bollu 2017-02-19 03:12:25
there is a more elegant way to write that I think? ^
lyxia 2017-02-19 03:12:29
> [8 .. 12] ^. traverse . to (+1)
lambdabot 2017-02-19 03:12:33
error:
lambdabot 2017-02-19 03:12:33
• Ambiguous type variable 'a0' arising from a use of 'show_M178707174857...
lambdabot 2017-02-19 03:12:33
prevents the constraint '(Show a0)' from being solved.
lyxia 2017-02-19 03:12:38
-_-
bollu 2017-02-19 03:12:44
> [8 .. 12] ^. traverse . to (+1) :: [Int]
bollu 2017-02-19 03:12:45
:)
lambdabot 2017-02-19 03:12:47
error:
lambdabot 2017-02-19 03:12:47
• No instance for (Enum [Int])
lambdabot 2017-02-19 03:12:47
arising from the arithmetic sequence '8 .. 12'
bollu 2017-02-19 03:13:01
> ([8 .. 12] ^. traverse . to (+1)) :: [Int]
lambdabot 2017-02-19 03:13:05
error:
lambdabot 2017-02-19 03:13:05
• No instance for (Enum [Int])
lambdabot 2017-02-19 03:13:05
arising from the arithmetic sequence '8 .. 12'
bollu 2017-02-19 03:13:07
no?
dramforever 2017-02-19 03:14:20
delYsid: May I ask you a question? Where did you learn about trifecta?
Tuplanolla 2017-02-19 03:15:37
> [8 .. 12] ^.. traverse . to (+ 1) -- One strategically placed dot, bollu.
lambdabot 2017-02-19 03:15:40
[9,10,11,12,13]
bollu 2017-02-19 03:17:10
Tuplanolla: ah
padre_angolano 2017-02-19 03:25:30
I used to run ghc7 in haskell98 compat mode using ghci --hide-package base --package haskell98, but ghc8 says there is no option --hide-package anymore. What's to be used instead?
lyxia 2017-02-19 03:29:30
padre_angolano: doesn't your ghc suggest -hide-package
nitrix 2017-02-19 03:37:02
SpaceX CRS-10, T minus 2 minutes. (https://www.youtube.com/watch?v=giNhaEzv_PI)
bollu 2017-02-19 03:38:22
:t (^..)
lambdabot 2017-02-19 03:38:24
s -> Getting (Endo [a]) s a -> [a]
bollu 2017-02-19 03:42:00
why does it need the endomorphisms on [a]? o_O
bollu 2017-02-19 03:42:06
wait, what is the type of Getting?
bollu 2017-02-19 03:42:11
:t Getting
lambdabot 2017-02-19 03:42:13
error:
lambdabot 2017-02-19 03:42:14
• Data constructor not in scope: Getting
lambdabot 2017-02-19 03:42:14
• Perhaps you meant one of these:
bollu 2017-02-19 03:42:21
yeah, that won't be around as it is a type alias
bollu 2017-02-19 03:42:30
Tuplanolla, lyxia: could you explain Getting to me?
lyxia 2017-02-19 03:44:02
bollu: type Getting r s a = (a -> Const r a) -> s -> Const r s, and Const r s is isomorphic to r. So Getting r s a = (a -> r) -> (s -> r)
bollu 2017-02-19 03:44:47
lyxia: and (^..) becomes (a -> Endo [a]) -> (s -> Endo [a])