Search Haskell Channel Logs

Monday, January 30, 2017

#haskell channel featuring ph88, EvanR, Logio, plakband, lambdabot, Ed___, and 6 others.

ongy 2017-01-30 09:45:29
:t readInt
lambdabot 2017-01-30 09:45:31
Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
ongy 2017-01-30 09:45:39
@hoogle readInt
lambdabot 2017-01-30 09:45:42
Numeric readInt :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
lambdabot 2017-01-30 09:45:42
Data.ByteString.Char8 readInt :: ByteString -> Maybe (Int, ByteString)
lambdabot 2017-01-30 09:45:42
Data.ByteString.Lazy.Char8 readInt :: ByteString -> Maybe (Int, ByteString)
plakband 2017-01-30 09:50:23
The repa docs state to "Add bang patterns to all function arguments, and all fields of your data types". Is there a reason not to simply use the STRICT pragma, or were the docs simply not updated for GHC 8?
Logio 2017-01-30 09:51:29
akfp: are you thinking of tasty-th?
Vlada 2017-01-30 09:51:45
Всем привет! I am from Moscow. Does anyone want to chat?
geekosaur 2017-01-30 09:52:29
plakband, the latter I'd imagine
Logio 2017-01-30 09:53:52
plakband: I remember reading that a few years back, so most likely the latter
plakband 2017-01-30 09:57:14
geekosaur, Logio: Thanks. I figured as much, but I don't really have intuition for strictness yet
teto 2017-01-30 10:07:11
how can I print the type of a variable in my script ?
geekosaur 2017-01-30 10:07:46
Data.Typeable... but that's a strange thing to do as types are compile time and *not* dynamic
geekosaur 2017-01-30 10:09:03
if you think you need to verify a type at run time, you are likely thinking about the problem wrong
geekosaur 2017-01-30 10:09:11
(wrong for Haskell at least)
teto 2017-01-30 10:16:43
geekosaur: I am learning haskell and you can do :t in ghci but once you try to runcommands from a file, I don't know how to do it. This would help me check I am correct (the error messages are not yet - always - clear to me)
EvanR 2017-01-30 10:16:49
question about the nature of backpack, is this like an answer to ML or ocaml "modules" ?
Ed___ 2017-01-30 10:17:22
How to convert a float to an integer? Like 1.56 -> 1
ongy 2017-01-30 10:17:31
:t round
lambdabot 2017-01-30 10:17:34
(RealFrac a, Integral b) => a -> b
geekosaur 2017-01-30 10:17:37
round, ceil, or floor
geekosaur 2017-01-30 10:17:41
or truncate
geekosaur 2017-01-30 10:17:47
depending on the exact behavior you want
EvanR 2017-01-30 10:17:50
teto: unfortunately, ghci is kind of a different self contained language, you dont run commands like that in regular haskell code
EvanR 2017-01-30 10:18:03
Ed___: floor
Ed___ 2017-01-30 10:18:07
Thanks guys!
EvanR 2017-01-30 10:18:10
> round 1.56
lambdabot 2017-01-30 10:18:14
2
geekosaur 2017-01-30 10:18:42
rightm that one is either truncate or floor (the difference between them shows up with negative values: truncate is toward 0, floor is always down)
geekosaur 2017-01-30 10:19:11
(ceil is always up, round is 4/5 rounding)
ongy 2017-01-30 10:19:52
4/5 rounding? I thought it's towards even?
geekosaur 2017-01-30 10:21:14
ah, yes, it is toward even, sorry
ph88 2017-01-30 10:21:22
is it possible to work with generics when you have a type like data Foo = F (Maybe Int) [String] ? all the example use less complicated types
glguy 2017-01-30 10:21:32
> map round [-3.5 .. 3.5]
ongy 2017-01-30 10:21:35
what's 4/5 rounding?
lambdabot 2017-01-30 10:21:35
[-4,-2,-2,0,0,2,2,4]
geekosaur 2017-01-30 10:21:39
(good example of the rounding issues discussed with decimal earlier :)
geekosaur 2017-01-30 10:22:04
0.0 .. 0.4x round down. 0.5 .. 0.9x up
ongy 2017-01-30 10:22:18
ah, ok
geekosaur 2017-01-30 10:22:19
so the 4/5 expresses the location of the breakpoint for rounding
ongy 2017-01-30 10:22:42
I read that as \frac{4}{5} first, which confused me a bit
EvanR 2017-01-30 10:24:48
> round 1.5
lambdabot 2017-01-30 10:24:52
2
EvanR 2017-01-30 10:24:54
> round 2.5
lambdabot 2017-01-30 10:24:58
2
EvanR 2017-01-30 10:25:12
bankers rounding
geekosaur 2017-01-30 10:25:30
yeh
geekosaur 2017-01-30 10:25:59
which is why my comment referencing the decimal discussion
Zemyla 2017-01-30 10:34:56
ph88: If you derive Generic, then you get to use it with anything that can take a Generic.
glguy 2017-01-30 10:37:10
ph88: Your question isn't specific about what a simpler type is, or what aspect of your example makes it complicated
ph88 2017-01-30 10:39:52
well here they describe a type with "a" https://hackage.haskell.org/package/base-4.9.1.0/docs/GHC-Generics.html Tree a and then replace all a's. But i have Int and String
ph88 2017-01-30 10:40:14
then this example doesn't have fields for the data constructor http://www.stephendiehl.com/posts/generics.html
ph88 2017-01-30 10:40:32
and this example also just takes a's https://jozefg.bitbucket.io/posts/2014-04-25-you-could-have.html
ph88 2017-01-30 10:40:48
which let's me think Generics only works with, what was it called, polymorphic type ?
ph88 2017-01-30 10:41:30
ok let's make it a bit easier, let's say i have a type data Foo = F (Maybe String) [String] so no mixed Int and String ..
glguy 2017-01-30 10:42:51
and what's your question about that type?
ph88 2017-01-30 10:44:47
as i understand it it should encode to something like Either (Maybe String) [String] .. still doable. But then i add another wrapped type data Foo = F Wrapper [String] data Wrapper = W (Maybe String) [String] now if have Left of Wrapper and left of (Maybe String) those types don't match so how am i suppose to implement :*: product ?