sternmull 2017-02-06 08:46:08
just out of curiosity: Is there a way to ask ghci or something else for the type of local bindings in a function?
ph88 2017-02-06 08:46:12
Tuplanolla, i made this out of it M.lookAhead $ c [void $ e delimitersNl, M.eof] because i noticed that eof was already returning () so i couldn't it together with e delimitersNl !
ertes 2017-02-06 08:46:18
(hint: (() <$) works without imports)
ertes 2017-02-06 08:46:28
:t (() <$)
lambdabot 2017-02-06 08:46:30
Functor f => f b -> f ()
ph88 2017-02-06 08:46:58
sternmull, what i know is that you can put the function to top-level and also put in a function signature with a type hole sternmull :: _
ertes 2017-02-06 08:47:34
sternmull: use a hole
ph88 2017-02-06 08:47:35
ertes, lol .. i was using () $> myself but then i got a ton more errors .. but i didn't know i was that close !
monochrom 2017-02-06 08:47:41
that also works in local bindings
monochrom 2017-02-06 08:48:03
> let {f = 1; f :: _} in f + length []
lambdabot 2017-02-06 08:48:07
error:
lambdabot 2017-02-06 08:48:07
• Found type wildcard '_' standing for 'Int'
lambdabot 2017-02-06 08:48:07
To use the inferred type, enable PartialTypeSignatures
sternmull 2017-02-06 08:48:11
ph88, ertes: Thanks. Will check that out.
ertes 2017-02-06 08:48:28
(note: partial type signature ≠ typed hole)
ertes 2017-02-06 08:48:32
and both work
monochrom 2017-02-06 08:49:34
Evidently, I am abusing PartialTypeSignatures without turning on PartialTypeSignatures to trick the compiler into teaching me type inference. It's a side effect. :)
ertes 2017-02-06 08:49:53
a useful one, too =)
monochrom 2017-02-06 08:50:21
Use "_ :: _" to trick the compiler into teaching you Haskell programming!
koala_man 2017-02-06 08:50:43
hahaha
takle 2017-02-06 08:51:18
Question: Why would one write a `case` as in the last example here https://lotz84.github.io/haskellbyexample/ex/switch
EvanR 2017-02-06 08:51:47
got a reference to a book which arrived today, huzzah: http://i.imgur.com/OwULUsA.jpg (From Frege to Godel: A sourcebook in mathematical logic)
EvanR 2017-02-06 08:52:14
the cover is quite ominous
jarlg 2017-02-06 08:55:43
Anyone got a good reference on (Lazy) ByteStrings?
jarlg 2017-02-06 08:58:31
Or, is there any required reading for understanding their implementation?
EvanR 2017-02-06 09:01:06
lazy ByteStrings are just lazy lists of strict bytestring chunks
EvanR 2017-02-06 09:01:23
internally
EvanR 2017-02-06 09:01:46
they are conceptually processed exactly as lazy lists would be
EvanR 2017-02-06 09:02:02
in haskell "list" is synonymous with lazy list
EvanR 2017-02-06 09:02:24
so perhaps read up on that topic?
jarlg 2017-02-06 09:03:37
EvanR: First I want to understand the difference between ByteString and [Word8], and then understanding lazyness/chunking I'll get lazy ByteStrings as well, right?
EvanR 2017-02-06 09:04:05
[Word8] is the type of lazy lists of Word8s, single bytes
ertes 2017-02-06 09:04:10
jarlg: the difference is the existence of toChunks and fromChunks
EvanR 2017-02-06 09:04:23
they take up more space and are slower than ByteStrings which are packed vectors of bytes
ertes 2017-02-06 09:04:32
other than that lazy ByteString and [Word8] are pretty much equivalent
ertes 2017-02-06 09:04:56
in terms of semantics… efficiency is of course an entirely different story
ertes 2017-02-06 09:05:40
in terms of efficiency it's best to think of lazy ByteString as [Data.ByteString.ByteString], which is reflected by fromChunks and toChunks
EvanR 2017-02-06 09:05:51
theyre not equivalent in terms of efficiency or semantics
EvanR 2017-02-06 09:05:59
list of bytes vs list of bytevectors
jarlg 2017-02-06 09:06:26
What's a "packed vector" and a "bytevector"?
EvanR 2017-02-06 09:06:31
fromChunks and toChunks converts between the two kinds of ByteStrings, does not involve [Word8]
ertes 2017-02-06 09:06:42
jarlg: ByteString
ertes 2017-02-06 09:06:51
the strict one that is
EvanR 2017-02-06 09:06:56
jarlg: behind the scenes its an array of raw bytes in memory, more efficient space-wise
jarlg 2017-02-06 09:06:59
ertes: I'm trying to understand ByteString ;)
EvanR 2017-02-06 09:07:13
in haskell you just know its an abstract data type
ertes 2017-02-06 09:07:21
jarlg: a strict ByteString is an array of Word8
EvanR 2017-02-06 09:07:28
you arent given the constructor for ByteString
ertes 2017-02-06 09:07:38
jarlg: "array" as in a continuous region in memory
ertes 2017-02-06 09:08:12
jarlg: in haskell we also say "vector" to talk about arrays, mainly because of the 'vector' library, which uses that terminology
ertes 2017-02-06 09:08:21
but it's unrelated to ByteString
EvanR 2017-02-06 09:08:39
the word "vector" is common when talking about arrays in lisp
EvanR 2017-02-06 09:08:58
for some reason
reactormonk 2017-02-06 09:09:35
Not sure if I can do the req/req2/req3 in a nicer way - http://lpaste.net/352148
ertes 2017-02-06 09:11:15
reactormonk: you could give (maybeModify hostL hostLens uri) a name, but i wouldn't… at some point extra names only introduce extra indirection, which makes code more difficult to read
ertes 2017-02-06 09:11:54
reactormonk: in fact i'd even question the utility of maybeModify (which you can write more nicely), but it's not too bad
jarlg 2017-02-06 09:11:56
EvanR, ertes: Thanks! I guess reading up on laziness is a good start to understanding it all better.
k0ral 2017-02-06 09:12:22
Hello guys
reactormonk 2017-02-06 09:15:31
ertes, more nicely? How?
EvanR 2017-02-06 09:24:18
jarlg: yeah, its kind of a brain explosion at first. but eventually it will make way more sense than eager-everything
BernhardPosselt 2017-02-06 09:31:02
just trying to dive a bit into haskell by implementing show for a custom type structure, but this wont compile http://dpaste.com/00NTN80
BernhardPosselt 2017-02-06 09:31:35
thats the error https://dpaste.de/H3EB
BernhardPosselt 2017-02-06 09:31:58
do i need to tell the compiler that a can be shown?
EvanR 2017-02-06 09:33:22
instance show (Tree a) where
EvanR 2017-02-06 09:33:27
i would guess is the issue
chef_excellence[ 2017-02-06 09:33:34
you call show for values of type a
chef_excellence[ 2017-02-06 09:33:47
you can fix this by adding Show a =>
EvanR 2017-02-06 09:34:06
instance Show a => Show (Tree a) where
chef_excellence[ 2017-02-06 09:34:12
instance Show a => Show Tree where ...
BernhardPosselt 2017-02-06 09:34:17
right that was the issue
chef_excellence[ 2017-02-06 09:34:23
* Tree a
BernhardPosselt 2017-02-06 09:34:28
when do i need to use ()?
EvanR 2017-02-06 09:35:02
Show Tree a is parsed as (Show Tree) a
EvanR 2017-02-06 09:35:09
but Show takes only one argument
ertes 2017-02-06 09:35:13
reactormonk: (f = \x y -> …) can be written as (f x y = …)
BernhardPosselt 2017-02-06 09:35:14
i see
EvanR 2017-02-06 09:35:26
some classes take more than one argument
EvanR 2017-02-06 09:35:36
like Convertible a b
sternmull 2017-02-06 09:36:00
i think its the same paring rule as for calling functions
sternmull 2017-02-06 09:36:16
s/paring/parsing/
ertes 2017-02-06 09:36:37
reactormonk: there is only one (very unfortunate) exception to that rule: you can't use that syntax in fields: A { field1 x = … } -- not allowed
ertes 2017-02-06 09:36:52
reactormonk: but in 'let' and 'where' it's generally allowed
BernhardPosselt 2017-02-06 09:39:52
do also have to take care of that when pattern matching?
BernhardPosselt 2017-02-06 09:39:53
e.g.
BernhardPosselt 2017-02-06 09:39:59
show (Node left value right)
BernhardPosselt 2017-02-06 09:40:05
instead of show Node left value right
chef_excellence[ 2017-02-06 09:41:39
jup