Search Haskell Channel Logs

Monday, January 30, 2017

#haskell channel featuring AWizzArd, lambdabot, dgpratt, monochrom, MarcelineVQ, Ptival, and 7 others.

ertes 2017-01-30 12:45:31
monochrom: does it? shouldn't it just be pointer comparison?
Cale 2017-01-30 12:45:34
Yeah, currently IORefs and MVars and such can be moved around by the garbage collector.
monochrom 2017-01-30 12:45:35
Take for example IORef, which wraps a STRef, which wraps a MutVar#, which is probably a machine address.
ertes 2017-01-30 12:45:39
ah, i see
ertes 2017-01-30 12:46:28
ok, then i wish vault's Data.Unique.Really were in base =)
monochrom 2017-01-30 12:46:30
I wonder how Java pulls it off though. (They don't have Ord, but they have Hashable, same issue.)
ertes 2017-01-30 12:46:50
they probably couple it with a unique identifier
monochrom 2017-01-30 12:47:42
Somehow no one complains about Java efficiency. Everyone laughs and then complain about company funding for hardware.
AWizzArd 2017-01-30 12:49:09
Ooh, I just discovered that I can do foo = let (Just f) = Just succ in f I only had to declare the type explicitly, and then it worked.
monochrom 2017-01-30 12:50:39
I think I am seeing a conspiracy theory here. Programmers and lower managers conspire to tell upper managers "we use Java, Java is best practice, this is why we need better computers". In secret, they use Haskell, and use the spare cycles of the overpowered computers for their own games and bitcoin mining.
lordcirth 2017-01-30 12:51:18
monochrom, or they do actually use Java, and just blame the language for their ineptitude. More believable :P
hpc 2017-01-30 12:51:23
dogecoin is a better investment nowadays
monochrom 2017-01-30 12:51:42
Yeah I'm out of touch in that area.
ertes 2017-01-30 12:52:13
hehe
monochrom 2017-01-30 12:52:20
lordcirth, but I want incredible conspiracy theories!
ertes 2017-01-30 12:53:05
AWizzArd: why are you matching (Just succ) against (Just f)?
ertes 2017-01-30 12:53:24
AWizzArd: foo = succ
monochrom 2017-01-30 12:53:52
foo = let f = succ in f
monochrom 2017-01-30 12:54:46
Is there a reason to bring in Just? Could you use list or Either or tuples?
monochrom 2017-01-30 12:55:07
foo = let [f, _] = [succ, succ] in f
monochrom 2017-01-30 12:56:16
. o O ( The perturbation method )
hpc 2017-01-30 12:56:26
watch your language ;)
monochrom 2017-01-30 12:58:28
OK!
ertes 2017-01-30 12:59:02
foo = let f : _ : _ : _ = [succ] in f
monochrom 2017-01-30 12:59:20
Hrm! I wonder if that bottoms out
ertes 2017-01-30 12:59:24
nope
ertes 2017-01-30 12:59:33
> let f : _ : _ : _ = [succ] in f 1
lambdabot 2017-01-30 12:59:35
*Exception: :3:5-26: Irrefutable pattern failed for pattern f :...
ertes 2017-01-30 12:59:38
huh?
monochrom 2017-01-30 12:59:41
See?
jle` 2017-01-30 12:59:50
f : ~(_ : _ : _) would be fine
ertes 2017-01-30 12:59:55
i thought let-patterns were irrefutable
jle` 2017-01-30 13:00:08
let patterns force evaluation
monochrom 2017-01-30 13:00:16
Yes but it is merely one outer ~
ertes 2017-01-30 13:00:22
ah, i see
jle` 2017-01-30 13:00:30
so f : _ : _ : _ forces ghc to evaluate [succ] to the extent that it knows it has three :'s
monochrom 2017-01-30 13:00:37
> case [succ] of ~(f:_:_) -> f 1
lambdabot 2017-01-30 13:00:39
*Exception: :(3,1)-(4,22): Irrefutable pattern failed for patte...
ertes 2017-01-30 13:00:46
jle`: i thought it were fully irrefutable
ertes 2017-01-30 13:01:28
i wish haskell were more consistent in that
monochrom 2017-01-30 13:01:28
I wrote a really long proof using merely Haskell 2010's equations for this kind of things.
ertes 2017-01-30 13:01:43
> (\(_, _) -> ()) undefined
lambdabot 2017-01-30 13:01:46
*Exception: Prelude.undefined
monochrom 2017-01-30 13:01:52
But it's lost somewhere on lpaste
ertes 2017-01-30 13:02:01
> let (_, _) = undefined in ()
dgpratt 2017-01-30 13:02:03
what's the language extension that allows you to easily bring record fields in scope in a function with a record type parameter?
lambdabot 2017-01-30 13:02:04
()
ertes 2017-01-30 13:02:17
dgpratt: you mean RecordWildCards?
dgpratt 2017-01-30 13:02:29
I think so, thanks ertes
ertes 2017-01-30 13:04:15
can a module import itself? would be quite useful with RecordWildCards (and shadowing in general)
ertes 2017-01-30 13:05:14
hmm, nope
hpc 2017-01-30 13:05:21
record wildcards don't deal with imports
ertes 2017-01-30 13:06:01
hpc: i found myself not using them in one case, because i needed access to the record accessors
ertes 2017-01-30 13:06:17
and writing Data.Blah.Myself.blah is awkward
ertes 2017-01-30 13:06:49
import Data.Blah.Myself as Self
ertes 2017-01-30 13:06:53
Self.blah -- less awkward
MarcelineVQ 2017-01-30 13:07:23
maybe have a module shortcut by default called This
ertes 2017-01-30 13:07:39
i'd vote for Me =)
MarcelineVQ 2017-01-30 13:07:50
there's already an disamiguity thing called this in another case, iirc
Koterpillar 2017-01-30 13:07:52
ertes: VB.Net?
ertes 2017-01-30 13:09:07
-XNarcissticModules
ertes 2017-01-30 13:10:46
-XNarcissisticModules
MarcelineVQ 2017-01-30 13:11:36
I​ guess I was wrong, 'this' isn't in the stolen syntax list for extentions
MarcelineVQ 2017-01-30 13:12:37
allthough neither is 'type' so maybe this is specific to code syntax
MarcelineVQ 2017-01-30 13:15:49
oh snap it's from -XPackageImports "The special package name this can be used to refer to the current package being built."
monochrom 2017-01-30 13:32:04
dgpratt: RecordWildCard lets you write "f StateT{..} = ... runStateT ...". RecordPuns lets you write "f StateT{runStateT} = ... runStateT ..."
dgpratt 2017-01-30 13:32:46
ah, interesting, thanks monochrom
dgpratt 2017-01-30 13:33:02
I wonder which one sees more use
monochrom 2017-01-30 13:33:11
Err, spelling error, NamedFieldPuns
monochrom 2017-01-30 13:33:27
And plural for RecordWildCards
monochrom 2017-01-30 13:33:37
English is so hard.
dgpratt 2017-01-30 13:34:09
for realz, thank goodness I learned it as a young child
monochrom 2017-01-30 13:34:11
I find that I use them together.
monochrom 2017-01-30 13:36:19
Wait, why do I use them together? That makes no sense.
ertes 2017-01-30 13:37:15
i've never used NamedFieldPuns
monochrom 2017-01-30 13:37:54
OK, I think I end up just using RecordWildCards more.
glguy 2017-01-30 13:37:57
monochrom: Maybe as your mood changes about how explicit you'd like to be: Mk { field1, .. }
monochrom 2017-01-30 13:38:22
Yeah.
Ptival 2017-01-30 13:39:02
is there a local way of indicating intended orphan instance?
monochrom 2017-01-30 13:39:20
But here is where NamedFieldPuns shines: You can use the pun on the RHS too. let runStateT = blahblah in StateT{runStateT}
jle` 2017-01-30 13:39:48
but ad-hoc polymorphism is super bad, right ...?
ertes 2017-01-30 13:39:56
Ptival: only module-local, as far as i know: {-# GHC_OPTIONS -Wno-orphan-instances #-}
glguy 2017-01-30 13:39:58
Ptival: If you're asking for a way to turn off the warning for one instance rather than the whole module, no
jle` 2017-01-30 13:40:00
monochrom: you can RWC on the right hand side too
Ptival 2017-01-30 13:40:11
whole module is good
jle` 2017-01-30 13:40:16
let runStateT = blablah in StateT{..}
ertes 2017-01-30 13:40:24
jle`: why?
monochrom 2017-01-30 13:40:36
Oh haha yes. Oh God, where does this madness end?!
jle` 2017-01-30 13:40:41
ertes: not sure why, but preventing it was the entire reason typeclasses were invented, right
jle` 2017-01-30 13:40:45
> let getSum = 10 in Sum{..}
lambdabot 2017-01-30 13:40:48
error:
lambdabot 2017-01-30 13:40:48
Illegal `..' in record construction
lambdabot 2017-01-30 13:40:48
Use RecordWildCards to permit this
jle` 2017-01-30 13:40:50
heh
ertes 2017-01-30 13:40:52
Ptival: sorry: OPTIONS_GHC, not GHC_OPTIONS
glguy 2017-01-30 13:40:52
Ptival: By default orphans don't generate a warning
jle` 2017-01-30 13:40:57
@let -XRecordWildCards
lambdabot 2017-01-30 13:40:57
Parse failed: TemplateHaskell language extension is not enabled. Please add ...
jle` 2017-01-30 13:40:59
oh
jle` 2017-01-30 13:41:07
@let {-# LANGUAGE RecordWildCards #-}
lambdabot 2017-01-30 13:41:09
Defined.
jle` 2017-01-30 13:41:10
i forgot if this works or not
monochrom 2017-01-30 13:41:11
OK! The real reason I turn on both is because I am too lazy to make up my mind!
jle` 2017-01-30 13:41:15
> let getSum = 10 in Sum{..}
lambdabot 2017-01-30 13:41:18
error:
lambdabot 2017-01-30 13:41:18
Illegal `..' in record construction
lambdabot 2017-01-30 13:41:18
Use RecordWildCards to permit this
ertes 2017-01-30 13:41:27
jle`: i don't know what the original intention was, but ad-hoc polymorphism and class polymorphism serve different purposes: convenience vs. abstraction
ertes 2017-01-30 13:41:29
respectively
monochrom 2017-01-30 13:41:57
ad-hoc is good or bad depending on details. The devil is in the details.
glguy 2017-01-30 13:42:00
ertes: -Wno-orphan-instances doesn't appear to be a valid flag, at least in 8.0.2
glguy 2017-01-30 13:42:06
ertes: perhaps -Wno-orphans
ertes 2017-01-30 13:42:11
ah, possibly
monochrom 2017-01-30 13:42:12
(Or is it "detail"? English is so hard.)
Ptival 2017-01-30 13:42:12
glguy: my .cabal has -Wall
jle` 2017-01-30 13:42:16
i admit that it is undeniable that the role that typeclasses play in haskell now are is very, very different than their intended purpose
jle` 2017-01-30 13:42:24
*original intended purpose
jle` 2017-01-30 13:42:47
same for newtypes
ertes 2017-01-30 13:44:00
ad-hoc polymorphism can cause trouble, but i'd say it's unlikely enough that the benefits outweigh the potential disadvantages
jle` 2017-01-30 13:44:22
there's also idris that just does TDNR
ertes 2017-01-30 13:44:40
jle`: yeah, that's what i mean by ad-hoc