mroman 2017-02-21 08:45:13
def f(a): return a*3 is already unsafe.
Cale 2017-02-21 08:45:31
plantedseed: I'm working at Obsidian Systems now, developing web applications for various clients entirely in Haskell. :)
mroman 2017-02-21 08:45:41
weird things can happen when you get types you didn't expect.
srhb 2017-02-21 08:46:20
sternmull: Oh, you found that faster than me, good. :-)
fresheyeball 2017-02-21 08:46:21
Cale: Nice!
mroman 2017-02-21 08:47:27
bollu: one has to accept to never fully understand Haskell though.
mroman 2017-02-21 08:47:31
At least I have to accept that.
mroman 2017-02-21 08:47:41
With my poor CS knowledge no chance :)
mroman 2017-02-21 08:48:26
that might actually be one reason why people wouldn't use it.
dmwit 2017-02-21 08:49:53
"fully understand Haskell" sounds like a no-true-Scotsman kind of thing
shapr 2017-02-21 08:49:59
mroman: lack of CS knowledge?
mroman 2017-02-21 08:50:12
yes.
mroman 2017-02-21 08:50:31
Some haskell extensions arguably can not be understood without a lot of theoretical CS background.
shapr 2017-02-21 08:50:36
dmwit: yeah, I learn new things about Haskell all the time. A friend just showed me TransformListComp and dramatically simplified my subway API code.
shapr 2017-02-21 08:50:49
mroman: I'm not convinced, got any specifics?
sternmull 2017-02-21 08:51:01
i think most people that use C++ only understand at most 80% or so of the language. I use it for over a decade every day and know that there are dark corners. I am new to haskell but it seems in haskell i have a much better chance to know every corner of the language.
mroman 2017-02-21 08:51:10
generic newtype deriving?
mroman 2017-02-21 08:51:25
functional dependencies
dmwit 2017-02-21 08:51:31
s/generic/generalized/ ?
shapr 2017-02-21 08:51:47
I thought fundeps were just extra switching on the type?
shapr 2017-02-21 08:52:32
mroman: I dunno, I wrote useful Haskell code before I ever had college courses about math or CS
mroman 2017-02-21 08:52:52
well yeah
mroman 2017-02-21 08:53:01
I can just wip everything up in IO if I want to.
mroman 2017-02-21 08:53:17
but there's still a lot of code and extensions I don't understand.
dmwit 2017-02-21 08:53:23
GND seems especially easy to understand without CS training. It just uses the same method implementations as the type the newtype wraps.
johnw 2017-02-21 08:53:25
fundeps just help unification; given Foo a b | a -> b, if you can infer Foo a c then for any Foo a d, c ~ d
johnw 2017-02-21 08:54:07
I think you're making Haskell seem more magical than it is
mroman 2017-02-21 08:54:31
do I look like I know what unification is :D?
shapr 2017-02-21 08:54:38
mroman: means makin stuff match
johnw 2017-02-21 08:54:59
if you means, knowing a implies knowing b. full stop.
dmwit 2017-02-21 08:55:48
I am sympathetic to mroman.
dmwit 2017-02-21 08:56:07
Advanced technology appears magical until you peer behind the curtain, and sometimes the curtain is thick and heavy and hard to move.
max3 2017-02-21 08:56:23
what is a CAF error?
johnw 2017-02-21 08:56:33
appearing magical, OK; being magical and thus "no one will ever understand it", not OK
mroman 2017-02-21 08:56:53
"fully"
dmwit 2017-02-21 08:56:57
max3: Perhaps you should post the exact text of the error. Probably the minimal code to cause it, too.
max3 2017-02-21 08:57:11
minimal code would be impossible
dmwit 2017-02-21 08:57:17
no
max3 2017-02-21 08:57:33
no?
dmwit 2017-02-21 08:57:36
illegal, maybe; impossible seems very unlikely to me
max3 2017-02-21 08:57:42
trust me impossible
dmwit 2017-02-21 08:57:48
I do not trust you.
max3 2017-02-21 08:58:29
it's 4 calls deep
max3 2017-02-21 08:58:33
i don't know what you want from me
max3 2017-02-21 08:58:44
especially given i'm just wondering what the identifier means
dmwit 2017-02-21 08:59:07
I want the minimal code that reproduces the error you're seeing, and the text of the error it causes.
mroman 2017-02-21 08:59:13
It's one thing to call "get" and "set" and one thing to understand how "MonadState" works and again another thing unterstand how "Monads" work and what you can do with them.
max3 2017-02-21 08:59:34
you're being unreasonable. i'm not asking for debug help - just a glossing
dmwit 2017-02-21 09:00:00
You're being unreasonable. You're asking for further information, but being completely opaque about what the topic is.
mauke 2017-02-21 09:00:03
how can you ask for help with an error without telling us what the error message is?
shapr 2017-02-21 09:00:06
mroman: I want to hear a list of magic things, because I'm sure I have much to learn.
mroman 2017-02-21 09:00:27
kind, rank types, type families
max3 2017-02-21 09:00:30
http://pastebin.com/Xci3zXP6
mroman 2017-02-21 09:00:35
those are all more or less still magical to me
shapr 2017-02-21 09:00:36
mroman: I enjoyed the magic of TransformListComp: https://github.com/shapr/tmuxmarta/blob/master/src/Lib.hs
shapr 2017-02-21 09:00:54
mroman: I think kind is just the type of the type
mroman 2017-02-21 09:01:03
shapr: yeh
mauke 2017-02-21 09:01:34
sounds like someone's evaluated undefined
mroman 2017-02-21 09:02:22
genericParseJSON
mroman 2017-02-21 09:02:25
that sounds magical :D
mroman 2017-02-21 09:02:46
how does Generic work
mroman 2017-02-21 09:02:52
that's some other questions on my ToDo list
shapr 2017-02-21 09:02:52
mroman: it was! I put "deriving Generic" on the record, and made sure the names matched, and the magic worked!
dmwit 2017-02-21 09:02:54
max3: "CAF" is only tangentially related to the error you posted. The real error is the last line.
mroman 2017-02-21 09:02:56
my todolist is full of things.
mroman 2017-02-21 09:03:36
`then group by station using groupWith` <- what the hell is that?
max3 2017-02-21 09:03:53
is it possible to make the result of a function strict?
dmwit 2017-02-21 09:04:01
max3: The previous four lines are a callstack that will help you find that error. The comment about a CAF is talking about a technical detail about `Prelude.undefined` that doesn't really matter for the purposes of fixing the problem.
mroman 2017-02-21 09:04:16
LINQ for Haskell?
shapr 2017-02-21 09:04:18
mroman: that's the TransformListComp extension fun
shapr 2017-02-21 09:04:21
mroman: pretty much
mbrock 2017-02-21 09:04:28
it would be an interesting case study to try to make the Nix (as in NixOS) language into a typed language. As it is, it's fairly successful despite being dynamically typed
shapr 2017-02-21 09:04:29
That's what I thought when I saw it, LINQ for Haskell
dmwit 2017-02-21 09:04:42
max3: "strict" is a property of functions. Consequently the answer to that is "yes" subject to the condition that the result of your function is another function.
shapr 2017-02-21 09:04:46
Mind you, LINQ was done by Erik Meijer, so really LINQ is Haskell for C#
mbrock 2017-02-21 09:04:48
so I wonder what kind of effort by what kind of experts would be required to think of and implement a good type system for Nix
mbrock 2017-02-21 09:05:16
as far as I know the original developers of that language were highly skilled functional programmers from the university of Utrecht
max3 2017-02-21 09:05:26
then i guess i meant is there a way to make a function strict
mroman 2017-02-21 09:05:27
that's not production level code though.
mroman 2017-02-21 09:05:42
no error handling.
dmwit 2017-02-21 09:06:00
max3: http://stackoverflow.com/q/15627849/791604
max3 2017-02-21 09:06:16
thank you
shapr 2017-02-21 09:07:00
mroman: oh, my code? It runs in my byobu/tmux status bar.
dmwit 2017-02-21 09:07:44
max3: However, I am worried. Is this question related to your previous one? If so, I don't think "making things strict" is going to help with "I did something that resulted in `undefined`".
dmwit 2017-02-21 09:07:54
max3: Making things stricter can only make them more undefined, not less.
max3 2017-02-21 09:08:22
i'm trying to do something probably dumb
max3 2017-02-21 09:08:24
i'll admit it
shapr 2017-02-21 09:08:33
I do that often.
max3 2017-02-21 09:08:51
this is probably the reason for the exception
max3 2017-02-21 09:08:51
http://pastebin.com/L08rHV01
max3 2017-02-21 09:09:35
i have loadConfig in a do somewhere else
max3 2017-02-21 09:09:46
and then its result is evaluated further on
max3 2017-02-21 09:10:43
yes
max3 2017-02-21 09:10:46
like i said
mroman 2017-02-21 09:10:58
databrary_configuration <- is that even used?
max3 2017-02-21 09:11:13
it's exported from the module
dmwit 2017-02-21 09:11:21
no
mroman 2017-02-21 09:11:49
and the fact that there's no '<-' smells indeed like unsafePerformIO
dmwit 2017-02-21 09:11:51
databraray_configuration, not databraryConfiguration
max3 2017-02-21 09:12:15
i was in here earlier asking how to access databrary_configuration
max3 2017-02-21 09:12:26
but i forget who said just export databraryConfiguration
dmwit 2017-02-21 09:12:58
I believe you are using unsafe* without understanding unsafe*.
dmwit 2017-02-21 09:13:09
I suggest considering how to achieve your goals without using unsafe*.
merijn 2017-02-21 09:13:17
@quote not.a.bug
lambdabot 2017-02-21 09:13:17
SPJ says: [This is] clearly not a bug in GHC; but it would be more felicitous if it gave you a warning...
merijn 2017-02-21 09:13:23
eh...wrong quote
merijn 2017-02-21 09:13:50
@quote Lemmih not.a.bug
lambdabot 2017-02-21 09:13:50
Lemmih says: "I don't understand why my code acts weird when I use unsafePerformIO" is not a bug.
merijn 2017-02-21 09:13:54
^ that one
dmwit 2017-02-21 09:14:49
"Understanding unsafe*" is also a potential solution. But I suspect once you do that you will wish to avoid using unsafe*, so the first solution is a shortcut.
max3 2017-02-21 09:15:01
i would prefer the latter
bitemyapp 2017-02-21 09:15:02
@karma+ dmwit
lambdabot 2017-02-21 09:15:03
dmwit's karma raised to 67.
max3 2017-02-21 09:15:54
i would prefer the latter
max3 2017-02-21 09:17:30
before i do a deep-dive on unsafe*
max3 2017-02-21 09:17:37
can someone tell me how to access the global variable?
max3 2017-02-21 09:17:44
databrary_configuration
max3 2017-02-21 09:17:44
?
mroman 2017-02-21 09:18:00
max3: http://codepad.org/A0LZVEav
dmwit 2017-02-21 09:18:47
max3: Yes, it is easy. Build the `IORef` once, in `IO`, at the beginning of `main`. Then pass the `IORef` everywhere it's needed.
dmwit 2017-02-21 09:18:59
This does not require unsafe*.
mroman 2017-02-21 09:19:21
vs. http://codepad.org/07PSMaJ4
max3 2017-02-21 09:19:37
dmwit, yes but there's no difference between that and passing what i've already been passing around (a config object)
max3 2017-02-21 09:19:47
i'm trying to avoid that in particular
dmwit 2017-02-21 09:19:51
mroman: Now predict: what does `case q of () -> case q of () -> return 1` do? Does it do that every time?
Cale 2017-02-21 09:20:06
max3: Sure -- if you're already passing a config object, you might want to put the IORef inside it
dmwit 2017-02-21 09:20:10
max3: Sorry, if your functions depend on a configuration, you can't avoid that.
mroman 2017-02-21 09:20:15
only a true haskell guru knows that.
mroman 2017-02-21 09:20:20
Which I am not :D
max3 2017-02-21 09:20:43
dmwit, are you saying that global-variables doesn't work?
Cale 2017-02-21 09:20:56
max3: I'd say just relax and pass the config around -- I've never actually regretted doing that.
dmwit 2017-02-21 09:21:02
max3: I am saying you should program as if global variables don't work.
dmwit 2017-02-21 09:21:32
It is easy to do and easy to get right.
dmwit 2017-02-21 09:21:40
The alternatives are easy to get wrong.
dmwit 2017-02-21 09:21:44
That seems like an easy choice to make to me.
max3 2017-02-21 09:21:58
that's fine. i'm a consenting adult
max3 2017-02-21 09:22:02
how do i do it?
mroman 2017-02-21 09:22:32
unsafePerformIO is not type safe.
mroman 2017-02-21 09:22:33
what.
mroman 2017-02-21 09:22:36
that's also magical :(
dmwit 2017-02-21 09:24:12
max3: You should begin by reading the documentation for `unsafePerformIO`.
mroman 2017-02-21 09:24:58
also demand analysis sounds magical too.
mroman 2017-02-21 09:25:08
just too much magical stuff in Haskell.
lassulus 2017-02-21 09:25:45
a
mroman 2017-02-21 09:28:04
isTrue# (x# <# 0#) && isTrue# (y# ># 0#) <- and wtf is that.
mroman 2017-02-21 09:28:08
magical. all magical.
Cale 2017-02-21 09:29:00
mroman: What was the thing that's magical?
Cale 2017-02-21 09:29:24
That's a bunch of unboxed operations, which by convention have their names end in #
Cale 2017-02-21 09:34:58
One reason unsafePerformIO breaks type safety is that newIORef :: IO (IORef a) is polymorphic, so if you unsafePerformIO it, you can let-bind something whose type is IORef a, which you can then proceed to read and write at different types
Cale 2017-02-21 09:36:02
This polymorphism isn't a problem without unsafePerformIO because you can't otherwise use the result polymorphically (it'll be bound via a lambda rather than let)
mroman 2017-02-21 09:37:19
but why can I even write to an IORef a?
Cale 2017-02-21 09:37:36
because you get to pick a
Cale 2017-02-21 09:37:39
every time
clmg 2017-02-21 09:37:53
Who here likes Haskell?
clmg 2017-02-21 09:37:56
I think it's great.
Cale 2017-02-21 09:38:06
I rather like it :)
mroman 2017-02-21 09:38:15
Isn't a an unbound type
clmg 2017-02-21 09:38:33
Haskell is more fun to write than other languages.
Cale 2017-02-21 09:38:41
you get something of type forall a. IORef a
Cale 2017-02-21 09:39:06
so you get to pick whatever a you like, at each usage site
clmg 2017-02-21 09:39:36
I'm writing a text editor. I wrote everything in Rust and then decided to translate it to Haskell. Joy.
mroman 2017-02-21 09:39:36
That ok.
mroman 2017-02-21 09:39:46
that's like existential types
mroman 2017-02-21 09:39:48
but
Cale 2017-02-21 09:39:56
No, universal types :)
mroman 2017-02-21 09:39:58
if it's a
Cale 2017-02-21 09:40:07
The usual sort of polymorphism you get without extensions
mroman 2017-02-21 09:40:09
I mean
nil_ 2017-02-21 09:40:14
mroman 2017-02-21 09:40:16
you cant' have a forall (Show s). s
mroman 2017-02-21 09:40:21
and then cast that to :: [Char]
nil_ 2017-02-21 09:40:24
Make that 30%, tops.
Tuplanolla 2017-02-21 09:40:37
Lens talk: I can overwrite values with `set (at i)`, but what if I only want to insert missing values?
mroman 2017-02-21 09:40:42
you can use show on it
Cale 2017-02-21 09:41:20
mroman: If you had a value of type forall s. Show s => s, then you'd be able to use it as a [Char]
Cale 2017-02-21 09:41:38
mroman: However, getting one of those which isn't simply undefined is going to be hard
Cale 2017-02-21 09:41:58
:t read "[1,2,3]"
lambdabot 2017-02-21 09:42:00
Read a => a
zennist 2017-02-21 09:42:01
[thumbsup]
Cale 2017-02-21 09:42:08
> read "[1,2,3]" :: [Integer]
lambdabot 2017-02-21 09:42:11
[1,2,3]
Cale 2017-02-21 09:42:14
> read "[1,2,3]" :: [Double]
lambdabot 2017-02-21 09:42:17
[1.0,2.0,3.0]
Cale 2017-02-21 09:42:20
> read "[1,2,3]" :: ()
lambdabot 2017-02-21 09:42:23
*Exception: Prelude.read: no parse
Cale 2017-02-21 09:42:34
^^ note, runtime exception rather than type error
phadej 2017-02-21 09:42:52
> readMaybe "[1,2,3]"
lambdabot 2017-02-21 09:42:56
error:
lambdabot 2017-02-21 09:42:56
Variable not in scope: readMaybe :: [Char] -> t
phadej 2017-02-21 09:43:01
> Text.Read.readMaybe "[1,2,3]"
lambdabot 2017-02-21 09:43:05
error:
lambdabot 2017-02-21 09:43:06
Not in scope: 'Text.Read.readMaybe'
lambdabot 2017-02-21 09:43:06
No module named 'Text.Read' is imported.
phadej 2017-02-21 09:43:09
:(
clmg 2017-02-21 09:44:04
Is fclabels objectively the best lens library?
Cale 2017-02-21 09:44:23
:t (\x -> let { r = System.IO.Unsafe.unsafePerformIO (Data.IORef.newIORef undefined) } in System.IO.Unsafe.unsafePerformIO $ do Data.IORef.writeIORef r x; Data.IORef.readIORef r)
lambdabot 2017-02-21 09:44:26
a1 -> a