mzabani 2017-03-06 10:52:45
hi everyone! Can someone explain me why my Monad Transformer's implementation fails to compile with "The coverage condition fails in class 'MonadReader' for functional dependency: 'm -> r'" when making it an instance of MonadReader such as: instance MonadReader r m => MonadReader r (TunnelT m) where?
c_wraith 2017-03-06 10:53:48
mzabani, because the first type argument doesn't start with a concrete type constructor.
c_wraith 2017-03-06 10:54:23
mzabani, that error is basically useless with MPTCs and fundeps
c_wraith 2017-03-06 10:54:33
mzabani, just turn on UndecidableInstances
mzabani 2017-03-06 10:54:51
but do I really have to turn on UndecidableInstances for this?
mzabani 2017-03-06 10:55:09
It feels kinda bad to do that
c_wraith 2017-03-06 10:55:14
why?
c_wraith 2017-03-06 10:55:36
UndecidableInstances is specifically to allow what you want to do.
monochrom 2017-03-06 10:55:39
mtl turns it on too. http://hackage.haskell.org/package/mtl-2.2.1/docs/src/Control-Monad-Reader-Class.html
mzabani 2017-03-06 10:55:46
Isn't UndecidableInstances basically saying that I'll guarantee correctness of my instances?
c_wraith 2017-03-06 10:55:53
no.
monochrom 2017-03-06 10:56:22
Where did you get that idea from?
mzabani 2017-03-06 10:56:22
hmm I didn't know mtl also used it..
c_wraith 2017-03-06 10:56:29
it just says "don't worry about monotonicity, instance resolution will terminate"
jle` 2017-03-06 10:56:37
undecidable instances has nothing to do with correctness of instances heh
mzabani 2017-03-06 10:56:59
oh, sorry about that, I'm pretty new to all this :P
jle` 2017-03-06 10:57:13
i wonder where the idea comes from
jle` 2017-03-06 10:57:18
maybe the name sounds scary?
mzabani 2017-03-06 10:57:31
haha it does a little bit
c_wraith 2017-03-06 10:57:38
well, it's unclear what the Undecidable part refers to.
jle` 2017-03-06 10:57:43
it's about as benign as TupleSections
c_wraith 2017-03-06 10:57:57
all it means is that instance resolution isn't guaranteed to terminate.
mzabani 2017-03-06 10:58:01
oh that is good to know!
Xnuk 2017-03-06 10:58:03
xa0: no i'm not
jle` 2017-03-06 10:58:08
Sections kinda sounds scary if you have trauma with discussion sections in university
ertes 2017-03-06 10:58:32
"undecidable" ≠ "unsafe" =)
jle` 2017-03-06 10:58:44
TupleSections sounds like a bad lecture section about tuples, who would want to turn that on?
ertes 2017-03-06 10:58:47
"undecidable" = "(something) might not terminate"
jle` 2017-03-06 10:58:48
:)
c_wraith 2017-03-06 10:59:08
if something goes wrong with UndecidableInstances, the worst case is a compiler error.
Koterpillar 2017-03-06 10:59:17
with Undecidable, what happens if I put in instances A a => A b and A b => A a?
c_wraith 2017-03-06 10:59:22
that's not too bad of a worst case.
Koterpillar 2017-03-06 10:59:32
or just something loopy
c_wraith 2017-03-06 10:59:40
Koterpillar, they'll be rejected as overlapping.
mzabani 2017-03-06 10:59:42
I was really under a very wrong impression on this. Thanks for clearing it out!
monochrom 2017-03-06 10:59:48
The compiler has a loop counter for this. "I give up after 5 iterations"
jle` 2017-03-06 11:01:16
psh wait until i submit my patch solving the halting problem
monochrom 2017-03-06 11:01:16
"and here is the flag you need if you want me to try 500 iterations"
c_wraith 2017-03-06 11:01:16
Koterpillar, allowing overlapping instances actually gets a little scary.
monochrom 2017-03-06 11:01:16
The problem with "meaningful" names.
Koterpillar 2017-03-06 11:01:43
I thought I could give priorities to overlapping instances?
Gurkenglas_ 2017-03-06 11:13:59
What's a better way to write fmap concat . sequenceA? (also y no more ircbrowse search)
jle` 2017-03-06 11:14:39
:t fmap concat . sequenceA
lambdabot 2017-03-06 11:14:41
(Traversable t, Applicative f) => t (f [a]) -> f [a]
monochrom 2017-03-06 11:16:18
If you change concat to join...
centril 2017-03-06 11:40:05
is there a lens, :t Lens' (Maybe a) a ?
johnw 2017-03-06 11:40:18
that's a Prism'
centril 2017-03-06 11:40:41
johnw: thinking of _Just ?
johnw 2017-03-06 11:40:51
yeah
robertkennedy 2017-03-06 11:41:18
:t findZero
lambdabot 2017-03-06 11:41:21
error: Variable not in scope: findZero
centril 2017-03-06 11:41:37
johnw: so... I have a lens: Lens' TcExpr (Maybe Type), and now I need a lens: Lens' TcExpr Type
centril 2017-03-06 11:41:42
johnw: is that doable?
johnw 2017-03-06 11:42:12
not as a lens, no
johnw 2017-03-06 11:42:22
what happens if the slot has a Nothing?
centril 2017-03-06 11:42:44
johnw: just skip it, hmm...
centril 2017-03-06 11:43:02
johnw: the best I can get is: :: Applicative f => (Type -> f Type) -> TcExpr -> f TcExpr
johnw 2017-03-06 11:43:03
a Traversal, Fold or Prism can "just skip", but a Lens cannot
centril 2017-03-06 11:43:37
which I guess fits into all lens functions since it's a stronger guaranteed than Functor f => ...
centril 2017-03-06 11:43:58
oh wait... no
centril 2017-03-06 11:44:08
the lens functions pick the functors, damn
ski 2017-03-06 11:44:14
the other way around, yes