Search Haskell Channel Logs

Sunday, February 19, 2017

#haskell channel featuring lpaste_, hpc, lambdabot, Tuplanolla, Welkin, sternmull, and 7 others.

Tuplanolla 2017-02-19 04:45:24
@hackage vector
lambdabot 2017-02-19 04:45:25
http://hackage.haskell.org/package/vector
Tuplanolla 2017-02-19 04:45:34
Try that one, thatguy.
thatguy 2017-02-19 04:47:52
Tuplanolla, thanks
Tuplanolla 2017-02-19 04:50:16
I wonder how one should go about adding dependent resources to `ResourceT`.
thatguy 2017-02-19 04:50:56
but how would I define safe addition between to vectors?
thatguy 2017-02-19 04:51:08
if I cannot fix their size
Tuplanolla 2017-02-19 04:51:20
You can't, as Welkin said, thatguy.
Welkin 2017-02-19 04:51:46
there is liquid haskell for dependent types
Welkin 2017-02-19 04:51:49
I've never used it though
Welkin 2017-02-19 04:52:35
https://github.com/ucsd-progsys/liquidhaskell/
thatguy 2017-02-19 04:53:05
so no one of you ever did such stuff? I mean everything I want to do is implement newtons method or gradient descent in R^n for some abstract function class with a gradient property
thatguy 2017-02-19 04:53:24
Am I doing something wrong or is this just way easier in imperative languages than in haskell?
sternmull 2017-02-19 04:54:51
thatguy: I think this is a problem with haskells type system. In C++ you can use integers as type parameters. This allows to describe NxM matrixes and the possible operations on them. As far as i know there is no way to do such thing in haskell.
ertes 2017-02-19 04:54:56
thatguy: the 'linear' package has such a type built-in
Tuplanolla 2017-02-19 04:55:23
It's not clear what you want to be fixed, thatguy.
sternmull 2017-02-19 04:56:44
I think he wants to define stuff like matrix vector products.
thatguy 2017-02-19 04:56:54
sternmull, yes integers as type parameters describes what I need I think
Tuplanolla 2017-02-19 04:57:11
There's a big difference between "user supplies size; program carries witness" and "programmer supplies size; template system creates specializations".
Tuplanolla 2017-02-19 04:57:40
The former can't be easily done in Haskell, but the latter is manageable with TH.
thatguy 2017-02-19 04:59:28
Tuplanolla, I want to have something like an abstract data type function which has some fixed dimension so that I have an evaluation, gradient and hesse matrix for that adt. and these gradient and hesse matrix will all depend of the dimension where the function operates in
thatguy 2017-02-19 04:59:37
but it could be that I am thinking this through very wrong
thatguy 2017-02-19 04:59:59
and this is done very differently in haskell
lpaste_ 2017-02-19 05:00:48
bollu pasted "observer-pattern-encoding" at http://lpaste.net/352715
lpaste_ 2017-02-19 05:00:52
bollu pasted "observer-pattern-encoding" at http://lpaste.net/352716
bollu 2017-02-19 05:01:01
is anyone familiar with the encoding of the observer pattern I am using?
bollu 2017-02-19 05:01:14
I think I can show that it is the same as a DFA with, like, "effectful" edges
bollu 2017-02-19 05:01:32
but I would love to hear everyone's thoughts
t4nk312 2017-02-19 05:09:20
Hello, friends! How do I declare mutiple constants in a single line in ghci? Like let x = 2 y = 5 in x*y
lyxia 2017-02-19 05:09:46
x = 2 ; y = 5
t4nk312 2017-02-19 05:10:02
Thank you!
hpc 2017-02-19 05:10:06
> let x = 2; y = 5 in x*y
lambdabot 2017-02-19 05:10:09
10
hpc 2017-02-19 05:10:28
> let {x = 2; y = 5} in x*y -- sometimes if you are getting parse errors this helps too
lambdabot 2017-02-19 05:10:31
10
ertes 2017-02-19 05:16:25
bollu: i suppose the existential 's' is a type for internal state?
bollu 2017-02-19 05:16:37
ertes: yep
bollu 2017-02-19 05:16:46
ertes: so that different observers can maintain custom state
ertes 2017-02-19 05:18:49
bollu: is the user of the observer supposed to use the updated observer in the next frame?
bollu 2017-02-19 05:20:22
ertes: no, I was thinking of it like "spawning a new actor on an event recieve"
bollu 2017-02-19 05:20:30
ertes: so, if you want, you can create a new observer
thatguy 2017-02-19 05:20:36
data Params a :: * can someone explain me what this means?
bollu 2017-02-19 05:20:51
which is what I do in the "mk_number_observer"
thatguy 2017-02-19 05:20:52
either I forgot or I have not seen such a declaration anywhere in the cis 194 tutorial
ertes 2017-02-19 05:20:59
bollu: how is the state supposed to change?
bollu 2017-02-19 05:21:20
ertes: ah, right, It's not. I'm just using it as Reader now
bollu 2017-02-19 05:21:34
ertes: hm, so I can the "s", right?
ertes 2017-02-19 05:21:44
bollu: i see… reason i ask is that there is a slightly different encoding of the same thing
bollu 2017-02-19 05:21:50
ertes: do tell
ertes 2017-02-19 05:21:51
bollu: *if* it were state
ertes 2017-02-19 05:22:01
if it's just reader, it doesn't matter
bollu 2017-02-19 05:22:06
ertes: I wanted to model the ability to create a new state
bollu 2017-02-19 05:22:12
to create a new observer*
ertes 2017-02-19 05:22:25
bollu: are you familiar with the automaton arrow?
bollu 2017-02-19 05:23:18
ertes: no
bollu 2017-02-19 05:23:21
ertes: that sounds interesting
ertes 2017-02-19 05:23:47
bollu: there are at least two ways to encode it… the following may look familiar to you:
ertes 2017-02-19 05:24:08
data Auto a b = forall s. Auto ((s, a) -> (s, b)) s
ertes 2017-02-19 05:24:17
a state transition function together with the current state
bollu 2017-02-19 05:24:46
ah, okay
ertes 2017-02-19 05:24:47
this is similar to your Observer, except that you're transforming into a monad, and that your state is not actually state
bollu 2017-02-19 05:24:50
yes
ertes 2017-02-19 05:25:03
data Auto m a b = forall s. Auto ((s, a) -> m (s, b)) s
bollu 2017-02-19 05:25:05
ertes: also, I'm transitioning into a new "Observer" as well
ertes 2017-02-19 05:25:19
yeah, now there is a different way to encode the same thing
bollu 2017-02-19 05:25:24
do tell
ertes 2017-02-19 05:25:40
newtype Auto m a b = Auto { stepAuto :: a -> m (b, Auto m a b) }
bollu 2017-02-19 05:26:15
hm, I see
bollu 2017-02-19 05:26:34
my type is just this with the extra (e -> Maybe a) thing
ertes 2017-02-19 05:26:35
the state value is no longer necessary, because the transition itself can carry state
bollu 2017-02-19 05:26:43
yeah
ertes 2017-02-19 05:26:54
like: countFrom x = Auto (\_ -> pure (x, countFrom (x + 1)))
ertes 2017-02-19 05:27:02
yeah, you have a filter
bollu 2017-02-19 05:27:05
yes, understood
bollu 2017-02-19 05:27:21
ertes: so the idea not new? :)
ertes 2017-02-19 05:27:51
well, consider this: Auto is a category (a Category in fact)
ertes 2017-02-19 05:28:19
if you could make filtering just another link in the automaton chain, then you no longer have to hardcode it into your type
ertes 2017-02-19 05:28:27
however, Auto is not quite powerful enough for that
bollu 2017-02-19 05:28:40
ertes: OK
ertes 2017-02-19 05:28:43
if you add the missing piece you essentially end up with Pipe from pipes =)
bollu 2017-02-19 05:28:46
ertes: so how do you add the extra power?
bollu 2017-02-19 05:28:48
oh xD
bollu 2017-02-19 05:28:56
so, wait, my type is isomorphic to Pipe?
bollu 2017-02-19 05:29:03
interesting :P
ertes 2017-02-19 05:29:14
nope, yours is similar to Consumer
ertes 2017-02-19 05:29:24
not sure if isomorphic, but very similar
bollu 2017-02-19 05:29:32
I see
bollu 2017-02-19 05:29:42
what does Pipe have that is "extrea"?
bollu 2017-02-19 05:29:46
extra*
ertes 2017-02-19 05:31:26
the way Auto is defined each output value corresponds to exactly one input value
ertes 2017-02-19 05:33:41
Pipe splits that up (here is what it might look like, if it were defined directly): newtype Pipe a b m r = Pipe (m (Step a b m r)); data Step a b m r = Done r | Get (a -> Pipe a b m r) | Put b (Pipe a b m r)
ertes 2017-02-19 05:34:04
it can consume without producing and vice versa
bollu 2017-02-19 05:35:34
ertes: hm
bollu 2017-02-19 05:36:02
ertes: I see
clmg 2017-02-19 05:37:22
I have two data constructores: Split and Window. Each window needs to link a parent Split and each split needs to link to two child Windows. How do I accomplish this?
lpaste_ 2017-02-19 05:43:10
bollu pasted "free-monad-gadt" at http://lpaste.net/352718
bollu 2017-02-19 05:43:20
why do people not encode the free monad this way?
bollu 2017-02-19 05:43:35
oh, wait, this is Free (Identity) a
leshow 2017-02-19 05:43:39
if I have a type like data Thing f a = Thing (f a). I expected the type to be * -> * -> *, because we have to apply an f and an a to the left side to get a concrete type. instead the kind is (* -> *) -> * -> * , why?
bollu 2017-02-19 05:43:43
give me 10
leshow 2017-02-19 05:43:55
kind sorry, not type
ertes 2017-02-19 05:44:11
bollu: perhaps because that's not free monads =)
bollu 2017-02-19 05:44:15
ertes: yeah xD
bollu 2017-02-19 05:44:19
ertes: let me modify it
bollu 2017-02-19 05:44:26
ertes: what I have is Free Identity a :P