hexagoxel 2017-02-22 13:45:49
>>>'s precedence is annoying sometimes; then you use .>
xcmw_ 2017-02-22 13:47:06
Does anyone know the answer to my question? Why doesn't Aeson give me back what I gave it?
Koterpillar 2017-02-22 13:47:43
xcmw_: because JSON can't encode Maybe (Maybe a) properly
dibblego 2017-02-22 13:47:58
can too, see argonaut.io
xcmw_ 2017-02-22 13:48:14
With an object it could
lyxia 2017-02-22 13:48:32
diagrams also encourages reverse function application
Koterpillar 2017-02-22 13:48:34
xcmw_: but that's not what you want
lyxia 2017-02-22 13:48:48
to set properties of elements
Koterpillar 2017-02-22 13:48:48
xcmw_: what's the result of encode [Just Nothing, Nothing]?
dmwit 2017-02-22 13:49:20
xcmw_: You're free to make your own `Maybe`-like type with better behavior.
Koterpillar 2017-02-22 13:49:24
like, what do you want it to be?
dmwit 2017-02-22 13:49:41
xcmw_: It is perhaps unfortunate that the behavior for `Maybe` is as it is, but it's also darn convenient in a lot of cases.
xcmw 2017-02-22 13:50:27
Koterpillar: compile time error
Welkin 2017-02-22 13:50:56
why would you ever have Maybe (Maybe a)?
Koterpillar 2017-02-22 13:51:10
then remove the instance for ToJSON a => ToJSON (Maybe a)
Koterpillar 2017-02-22 13:51:34
Welkin: it comes up if someone already has a Maybe a and you are wrapping it for another reason
xcmw 2017-02-22 13:51:34
Welkin: I was just testing to see if the library could handle tricky edge cases
dmwit 2017-02-22 13:51:39
Welkin: Because you have a database query operation that can fail, and even if it succeeds it can not match any records.
Koterpillar 2017-02-22 13:51:59
(arguably that can be Either DBError (Maybe a), but well)
dmwit 2017-02-22 13:52:08
Nothing means the connection failed. Just Nothing means the query went through and didn't match. Just (Just foo) means the query went through and matched record foo.
Welkin 2017-02-22 13:52:12
I still don't see why
Welkin 2017-02-22 13:52:22
I never had that issue using something like Persistent
Welkin 2017-02-22 13:52:38
it produced a Maybe Entity
dmwit 2017-02-22 13:52:46
You really can't see why composing two systems that each could fail might be useful occasionally?
dmwit 2017-02-22 13:52:59
And being able to distinguish between which system failed?
Welkin 2017-02-22 13:53:42
why does it matter? If the lookup fails, it fails
dmwit 2017-02-22 13:54:05
Because in one case I'm going to try to reestablish the connection, and in the other I'm going to tell the user nothing matched.
dmwit 2017-02-22 13:54:15
For example.
Welkin 2017-02-22 13:54:16
database access is handled in IO anyway
Welkin 2017-02-22 13:54:20
there are no Maybes involved
Koterpillar 2017-02-22 13:54:23
doesn't have to be
dmwit 2017-02-22 13:54:28
...
Koterpillar 2017-02-22 13:54:49
Welkin: surprise: there are different ways to do things!
hexagoxel 2017-02-22 13:55:18
dmwit: let me guess, you want to go back to the constructive discussion about operators? what is (...) supposed to be? :D
dmwit 2017-02-22 13:56:05
hexagoxel: it's the partial application of function composition to enumFromTo, obviously
lyxia 2017-02-22 13:56:27
but... applied which way
dmwit 2017-02-22 13:56:51
yes
xcmw_ 2017-02-22 13:58:15
Is there a haskell oriented serialization library? Or will readMaybe and show work?
peddie 2017-02-22 13:58:41
@hackage binary -- xcmw
lambdabot 2017-02-22 13:58:41
http://hackage.haskell.org/package/binary -- xcmw
peddie 2017-02-22 13:59:04
xcmw_: depending on what you want there are libraries for serializing to a bunch of other formats too
dmwit 2017-02-22 14:00:32
readMaybe and show will work, but read* is notoriously slow.
ezyang 2017-02-22 14:00:39
when I say import A(K(..)), is it always guaranteed that the type constructor K comes into scope?
ezyang 2017-02-22 14:01:56
relatedly, what's the name of the feature where you can associate pattern synonyms with a type for export?.
lyxia 2017-02-22 14:02:00
is this a trick question
ezyang 2017-02-22 14:02:22
sort of. In Haskell98 I think the answer is YES
ezyang 2017-02-22 14:02:26
but I'm not sure about GHC Haskell
Axman6 2017-02-22 14:02:35
ezyang: this is worrying, you're who we turn to when we have these questions :P
lyxia 2017-02-22 14:03:24
https://github.com/ghc-proposals/ghc-proposals/pull/28
ezyang 2017-02-22 14:03:41
aha! pattern synonym bundling.
ezyang 2017-02-22 14:03:42
Thank you
lyxia 2017-02-22 14:03:49
yw
xcmw 2017-02-22 14:09:43
peddie: Thanks. Binary works
dmwit 2017-02-22 14:33:32
ezyang: Interpreting your answer in the strictest possible sense I think the answer is NO even in H98/H2010.
dmwit 2017-02-22 14:34:16
ezyang: I believe `module A (K) where type K a = Int` and `import A(K(..))` is legal in H98, but `K` is not a type constructor.
dmwit 2017-02-22 14:35:10
In case you weren't intending "constructor" in the Report sense, then I'm a bit confused because it seems "obvious" that `K` would be in scope (assuming it compiled at all).
dmwit 2017-02-22 14:37:09
(There is a warning -- `-fwarn-dodgy-imports`, I think -- for this.)
ezyang 2017-02-22 14:43:32
dmwit: I didn't intend constructor in the report sense, so yes, obviously it's in scope :)
ezyang 2017-02-22 14:44:24
I guess what is giving me trouble is that GHC's formulation of export lists is such that there is a form where MkK is brought into scope but K is not
ezyang 2017-02-22 14:44:38
for example, if I say module A (pattern MkK) where data K = MkK