Search Haskell Channel Logs

Monday, January 30, 2017

#haskell channel featuring RyanGlScott, orion, jophish, Profpatsch, Ferdirand, merijn,

Ferdirand 2017-01-30 03:52:05
merijn: well, my point is, you can model IO as State RealWorld, grr12314 seemed to have an intuition of that
Ferdirand 2017-01-30 03:52:23
okay maybe it would have been more correct to say they grokked the state monad
c_wraith 2017-01-30 03:52:47
I think that's a terrible way to think of IO.
merijn 2017-01-30 03:52:53
c_wraith++
merijn 2017-01-30 03:53:01
RealWorld is a filthy lie
merijn 2017-01-30 03:53:19
And breaks as soon as we talk about concurrency
RyanGlScott 2017-01-30 03:53:27
I have a singletons question
RyanGlScott 2017-01-30 03:53:34
I know how to use singletons to promote values to the type level
RyanGlScott 2017-01-30 03:53:40
But is it possible to do the reverse?
RyanGlScott 2017-01-30 03:53:46
e.g., in Idris you have this definition:
RyanGlScott 2017-01-30 03:53:49
the : (a : Type) -> (value : a) -> a; the _ = id
c_wraith 2017-01-30 03:54:00
It's much better to think of IO as a free monad with a primitive operation corresponding to "run this native code"
RyanGlScott 2017-01-30 03:54:05
Is it possible to write something morally equivalent to this today using singletons?
c_wraith 2017-01-30 03:54:56
That's not how it's actually implemented, but it gives you the correct mental model for IO.
merijn 2017-01-30 03:55:29
RyanGlScott: If you enjoy lots of pain, then you can approximate it
RyanGlScott 2017-01-30 03:55:43
Well, I didn't come for a haircut. How much pain are we talking? :)
c_wraith 2017-01-30 03:55:54
search for "Hasochism". :)
merijn 2017-01-30 03:55:56
RyanGlScott: The original paper is called 'Hasochism' ;)
merijn 2017-01-30 03:56:28
I believe Stephanie (Weirich) has a few papers on it too
RyanGlScott 2017-01-30 04:00:47
c_wraith, merijn: Thanks. It's not immediately obvious where in the paper they discuss this trick, though, so I'll have to read it more carefully.
Tuplanolla 2017-01-30 04:01:24
I take it you're familiar with how `Proxy` and `ScopedTypeVariables` allow something similar, RyanGlScott.
RyanGlScott 2017-01-30 04:02:23
Tuplanolla: Sure. I was just wondering if singletons provided some sugar for this sort pattern.
RyanGlScott 2017-01-30 04:02:34
Or perhaps the answer really is "just use Proxy/TypeApplications"
merijn 2017-01-30 04:02:34
RyanGlScott: I recall a paper on a "dependent" red-black tree for GHC by Stephanie, but I can't quickly find it
merijn 2017-01-30 04:04:32
RyanGlScott: I think that one included reifying the type-level depth at runtime
RyanGlScott 2017-01-30 04:04:42
Actually, I think that is the answer, according to slide 27 of https://www.cis.upenn.edu/~sweirich/talks/icfp14.pdf
RyanGlScott 2017-01-30 04:05:01
Weirich identifies (x : A) -> B with forall (x :: A). Sing x -> B
RyanGlScott 2017-01-30 04:06:01
She also talks about red-black trees in that presentation, too
merijn 2017-01-30 04:06:23
RyanGlScott: Yeah, that's the one I was thinking of, except there's also a full paper iirc
roxxik 2017-01-30 04:09:04
grr12314: i'm a little late to this discussion, but if you want to know the details: http://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/mark.pdf
roxxik 2017-01-30 04:13:07
one mistake in there is using "IO Monad" too often, while it should read "IO Type", this way of doing IO is called monadic IO for the reason that monads were new at that time and there were already other aproaches to IO. it's true, that the IO Type supports monadic composition (there is an instance Monad IO), and thus allows us to programm imperatively
roxxik 2017-01-30 04:14:02
note: https://blog.jle.im/entry/io-monad-considered-harmful.html
orion 2017-01-30 04:33:16
What's the current consensus on postgres migration in Haskell?
jophish 2017-01-30 04:34:39
orion: I looked into this quite carefully recently. I settled on using postgresql-simple-migration
jophish 2017-01-30 04:35:02
dbrecord-opaleye looks very promising, but it's not in a usable state at the moment
jophish 2017-01-30 04:35:50
I started writing some fancy automatic conversion functionality myself, but determined that I'd never save time doing that compared to just writing the SQL by hand, and using p-s-m
Profpatsch 2017-01-30 04:37:37
ifE f = if errs /= [] then f else id
jophish 2017-01-30 04:37:41
It's really easy to use, however it only handles a linear sequence of migrations, nothing fancy.
Profpatsch 2017-01-30 04:37:45
I'm missing a combinator, aren't I?
jophish 2017-01-30 04:38:42
Profpatsch: you can use `null` instead of `== []`
jophish 2017-01-30 04:38:59
but I think you wanted to replace all of 'ifE'
orion 2017-01-30 04:39:42
jophish: I guess postgresql-simple-migration is intended to be used with postgresql-simple? How is that package?
jophish 2017-01-30 04:40:06
orion: I've not had anything to do with it. I use opaleye for everything
jophish 2017-01-30 04:40:14
(aside from one command when setting up the db)
Profpatsch 2017-01-30 04:41:50
jophish: Yes; do you know if null is more performant than /= []?
jophish 2017-01-30 04:42:56
well, both are going to be very cheap.
roxxik 2017-01-30 04:43:03
just lookup instance Eq a => Eq [a] and null
jophish 2017-01-30 04:43:09
null doesn't require passing a dictionary around though
roxxik 2017-01-30 04:43:15
should both break down to a pattern match
Profpatsch 2017-01-30 04:44:48
For Text the null function matches on the internal len field and checks len <= 0