Search Haskell Channel Logs

Saturday, February 25, 2017

#haskell channel featuring EvanR, Sornaensis, lambdafan, exio4, dolio, wyhgood,

lambdafan 2017-02-25 13:51:58
I'm trying to read a UTF-8 encoded file one character at a time, could someone recommend to me a good way to do it?
lambdafan 2017-02-25 13:52:09
it's fine if the file itself is in memory all at once.
c_wraith 2017-02-25 13:53:22
lambdafan: read it as Text then convert it to a String?
lambdafan 2017-02-25 13:56:35
c_wraith: my understanding is that utf-8 is really inefficient as String.
c_wraith 2017-02-25 13:57:06
you said "one character at a time". That's exactly what String is
lambdafan 2017-02-25 13:57:19
fair enough
c_wraith 2017-02-25 13:58:13
Anyway, converting Text to a String is properly lazy
c_wraith 2017-02-25 13:58:33
If you don't keep multiple characters from the String in memory at once, the only copy of them will be in the Text value
lambdafan 2017-02-25 13:59:14
when you ay convert I am imagining somethig like this
lambdafan 2017-02-25 13:59:32
Data.Text.unpack <$> readFile "foo"
c_wraith 2017-02-25 13:59:40
Yep
c_wraith 2017-02-25 14:00:18
But that doesn't change unpack's laziness properties
lambdafan 2017-02-25 14:00:21
oh I thing I was making this harder than it had to be. I was believing I should stay away from String
c_wraith 2017-02-25 14:00:35
You *could* use a fold in Text, too
c_wraith 2017-02-25 14:00:42
Those also handle one character at a time
c_wraith 2017-02-25 14:01:01
If you found one the right shape for your problem
lambdafan 2017-02-25 14:01:22
Well, ideally I would like a single character to inhabit a Text, such that I end up with a [Text]
exio4 2017-02-25 14:02:27
lambdafan: you can use Data.Text.Lazy
c_wraith 2017-02-25 14:02:40
I guess that's approximately the same memory use as String, due to slicing..
exio4 2017-02-25 14:02:40
which is "basically" a lazy list of Text chunks
lambdafan 2017-02-25 14:04:35
hmm okay I will stick with String
EvanR 2017-02-25 14:34:25
alan turing wrote about a "universal machine" which could compute the same output sequence as any other turing machine, and lots of articles simply refer to "machines" and the simulation of machines.
EvanR 2017-02-25 14:34:50
im wondering how appropriate it is to shorten it to machines. Since I am looking up info on motors and weird looking gears
EvanR 2017-02-25 14:35:05
is a universal turing machine able to simulate those?
EvanR 2017-02-25 14:35:43
if not, in what way are turing machines and state machines... machine-like?
c_wraith 2017-02-25 14:36:12
the turing machine was conceptualized as a physical device.
c_wraith 2017-02-25 14:36:27
with a few implausible details like infinite storage space.
c_wraith 2017-02-25 14:36:44
But other than those, it's plausible to construct as a mechanical device
Sornaensis 2017-02-25 14:37:29
they are a machine because they transition from state to state and read and write to a tape, mechanically
c_wraith 2017-02-25 14:38:16
Infinite write/erase is also implausible. But you can design something that works for quite a while, at least.
dolio 2017-02-25 14:38:31
Can a Turing machine simulate a pulley?
dolio 2017-02-25 14:38:37
Or an incline plane?
c_wraith 2017-02-25 14:38:43
yes, just incline it. :)
EvanR 2017-02-25 14:38:50
realization as an actual machine i think was a side issue, the point was that some idealized mathematician who could only follow instructions and not do real thinking was shown to be unable to do stuff like solve the halting problem, and thus not solve the entscheidung problem as a special case
EvanR 2017-02-25 14:39:29
godel incompleteness, from a few years before, ended up being a special case
EvanR 2017-02-25 14:40:13
then a few years later people starting trying to model the human brain as a machine
EvanR 2017-02-25 14:40:20
which seems odd
EvanR 2017-02-25 14:40:48
but yes i am wondering about the machine aspects, like pulleys and worm screws
EvanR 2017-02-25 14:41:07
are we dealing with two notions of machines
c_wraith 2017-02-25 14:41:36
I don't really understand the question. The universal turing machine can emulate any turing machine. It was never claimed it could emulate primitive physical machines.
dolio 2017-02-25 14:41:54
Yes, of course. Turing machines are expected to simulate other kinds of machines that do computation.
dolio 2017-02-25 14:42:11
Not machines that distribute force or whatever.
EvanR 2017-02-25 14:42:22
so strictly, its about turing machines, more loosely any machine that does computation?
EvanR 2017-02-25 14:42:31
or is that already out of the bounds of certainty
c_wraith 2017-02-25 14:43:27
Well, the church-turing thesis claims that a turing machine (and lambda calculus) are at least as powerful as any other formalized computation system.
EvanR 2017-02-25 14:43:35
and today we talk about computers colloquially as "machines", even if they dont seem anything like force distribution
c_wraith 2017-02-25 14:43:47
That hasn't been proven, as far as I know, but it is pretty much assumed.
EvanR 2017-02-25 14:43:50
except maybe the cpu fan
c_wraith 2017-02-25 14:44:11
and the graphics card fan!
EvanR 2017-02-25 14:44:52
i need to read this church-turing thesis
EvanR 2017-02-25 14:45:01
if its even a real paper
nak 2017-02-25 15:42:11
does someone want to walk me thru the last line of http://hackage.haskell.org/package/base-4.9.1.0/docs/src/Data.OldList.html#transpose
centril 2017-02-25 15:42:19
is there some nice lens thingy to apply a function to both operands of a binary operation and then do a fold on the results ?
nak 2017-02-25 15:42:51
i understand up thru : transpose ((x:xs) : xss) = (x : ... then i struggle with [h | (h:_) <- xss]) : transpose (xs : [ t | (_:t) <- xss])
centril 2017-02-25 15:43:00
each operand is a product of types
nak 2017-02-25 15:43:13
what is [ h | (h:_) <- xss] ?
nak 2017-02-25 15:43:29
is that some list comprehension ?
centril 2017-02-25 15:43:45
nak: yeah, it is
nak 2017-02-25 15:43:50
given [[1,2,3]] will that give me [1] ?
centril 2017-02-25 15:44:27
nak: seems about right
centril 2017-02-25 15:44:36
you can always test it =)
wyhgood 2017-02-25 15:44:42
hello