Search Haskell Channel Logs

Friday, February 3, 2017

#haskell channel featuring pikajude, monochrom, Gurkenglas, Jello_Raptor, Welkin, erisco, and 9 others.

monochrom 2017-02-03 13:45:23
@type asTypeOf
lambdabot 2017-02-03 13:45:24
a -> a -> a
monochrom 2017-02-03 13:46:00
That one also does const but extracts type.
Welkin 2017-02-03 13:46:14
how can it extract the type?
Welkin 2017-02-03 13:46:18
types don't exist at runtime
geekosaur 2017-02-03 13:46:34
it's just const with a type signature
monochrom 2017-02-03 13:46:36
Sure, I am not using precise wording. You have a better word?
geekosaur 2017-02-03 13:46:45
:t const
lambdabot 2017-02-03 13:46:47
a -> b -> a
Welkin 2017-02-03 13:46:55
no, I am just cursious what you mean
geekosaur 2017-02-03 13:47:27
now just give it a type signature that forces b ~ a
monochrom 2017-02-03 13:47:59
Perhaps I'll stick to "astral projection".
Zemyla 2017-02-03 13:48:18
Types sometimes exist. Like with Typeable.
mniip 2017-02-03 13:49:07
those aren't types
mniip 2017-02-03 13:49:22
that's type information
monochrom 2017-02-03 13:49:26
People really like to pick and argue, no?
mniip 2017-02-03 13:49:33
yeah
erisco 2017-02-03 13:50:07
Welkin, well with GADTs you have some information
nshepperd 2017-02-03 13:50:21
typeclass dictionaries exist at runtime!
mniip 2017-02-03 13:50:31
erisco, only dicts and coercions!
nshepperd 2017-02-03 13:50:34
(and that's what sNatToInt is using)
erisco 2017-02-03 13:50:37
yes
Zemyla 2017-02-03 13:50:48
@let data Dyn' where { Dyn' :: (Typeable a) => a -> Dyn' }
lambdabot 2017-02-03 13:50:50
Defined.
erisco 2017-02-03 13:50:57
but you can also do this statically. geekosaur gives one example
bennofs2 2017-02-03 13:51:10
Can anyone tell me what I'm doing wrong here? https://github.com/bennofs/repros/tree/master/ghc/ffi-segfault
bennofs2 2017-02-03 13:51:21
running script.sh gives segfault
geekosaur 2017-02-03 13:52:17
failing to return p from make_struct?
bennofs2 2017-02-03 13:53:02
geekosaur: wow... thanks!
bennofs2 2017-02-03 13:53:09
geekosaur: such obvious
monochrom 2017-02-03 13:54:19
The type checker of C ought to flag this.
bennofs2 2017-02-03 13:54:43
I should've turned on warnings for the c compiler...
geekosaur 2017-02-03 13:54:51
-Wall should have caught it. for historical reasons it's not a default
geekosaur 2017-02-03 13:55:01
(K&R has many sins to answer for)
bennofs2 2017-02-03 13:55:20
Or, wait a minute, didn't I just ignore some warning because it didn't look relevant? lol
Gurkenglas 2017-02-03 13:55:50
It is said that https://wiki.haskell.org/Roll_your_own_IRC_bot is bad. Should that page be marked as deprecated, then? Should https://github.com/bitemyapp/learnhaskell/blob/master/code_to_learn_from.md stop linking there?
monochrom 2017-02-03 13:56:26
Is it also said why the page is bad?
erisco 2017-02-03 13:56:47
can anything be as bad as the invention of null, though
geekosaur 2017-02-03 13:57:02
and also that should probably have warned even without -Wall because its return type isn't (int)
monochrom 2017-02-03 13:57:09
The perpetuation of null is worse than the invention of null.
erisco 2017-02-03 13:57:39
all your data may or may not exist. Have fun programming!
hpc 2017-02-03 13:58:43
null is self-perpetuating though, because of the train of thought it has created
hpc 2017-02-03 13:58:54
try and take it away, and people will think you would rather be using -1 as "null"
monochrom 2017-02-03 13:59:42
I almost thought you were to say "give them the hope of null, then take it away" :)
hpc 2017-02-03 14:01:06
no, that's C++ references
Welkin 2017-02-03 14:01:45
null and undefined
erisco 2017-02-03 14:06:55
is it bad to kind restrict in data/newtype parameters?
monochrom 2017-02-03 14:08:05
Probably yes but don't worry too much.
erisco 2017-02-03 14:10:58
I look and, for example, :k Vector :: * -> Nat -> *
erisco 2017-02-03 14:11:50
so that actually forces me to add the same constraint to my types should they be defined with Vector
monochrom 2017-02-03 14:12:57
Ah but that's because Vector is actually a container of real data.
monochrom 2017-02-03 14:13:44
No one is going to really request "i_want_to_implement :: Vector Either 5"
erisco 2017-02-03 14:14:12
I am referring to Nat moreso
monochrom 2017-02-03 14:14:54
OK, but the Nat there is under even less need to generalize.
erisco 2017-02-03 14:16:16
was it ever really a point of need when it came to contexts? I thought the point was we don't know the needs ahead of time
monochrom 2017-02-03 14:17:07
OK, there is a balance between how much you can generalize and how much you can implement.
monochrom 2017-02-03 14:18:01
I know how to implement "Vector (IO Int) 10". I don't know how to implement "Vector IO [Int]".
monochrom 2017-02-03 14:18:57
And I suspect that if one day someone claims to "need Vector IO [Int]" it is likely going to be nonsense.
pikajude 2017-02-03 14:22:18
a vector of IO!
erisco 2017-02-03 14:22:57
with a list of possible sizes
ch4rli3_unicorn 2017-02-03 14:30:52
roar
erisco 2017-02-03 14:35:05
why might this be the case http://lpaste.net/352066
jle` 2017-02-03 14:35:53
erisco: what definitions of SNat/Nat are you using?
Jello_Raptor 2017-02-03 14:36:04
is there a standard way to get a pile of different WriterTs (or the like) playing well together? I see ether has tagged transformers, but right now the most straightforward approach is just use a concrete stack with functions that have lots of lifts in them
erisco 2017-02-03 14:36:24
from Data.Type.Natural
jle` 2017-02-03 14:36:45
Jello_Raptor: you can write natural transformations to convert your different writer's into one mega-writer type?
erisco 2017-02-03 14:36:53
I just threw RankNTypes in there and I don't know them all that well... probably where this is going wrong
jle` 2017-02-03 14:36:57
erisco: what package?
erisco 2017-02-03 14:37:02
type-natural
erisco 2017-02-03 14:37:18
http://hackage.haskell.org/package/type-natural-0.7.1.2/docs/Data-Type-Natural.html
jle` 2017-02-03 14:38:58
erisco: i think you might have wanted to make an existential type
erisco 2017-02-03 14:39:26
how do I define that
jle` 2017-02-03 14:39:55
added an annotation
jle` 2017-02-03 14:40:23
right now you have it as sa RankN type which I don't think is what you want, if i'm interpreting the names of your constructors/types properly
erisco 2017-02-03 14:40:50
"A newtype constructor cannot have a context in its type" hrm
erisco 2017-02-03 14:41:05
yes the forall doesn't seem right at that position
jle` 2017-02-03 14:41:33
aded a version using GADT syntax, which feels abit more natural to me
jle` 2017-02-03 14:41:38
ah i see, you probably can't have it be a newtype
jle` 2017-02-03 14:41:40
it probably has to be 'data'
erisco 2017-02-03 14:42:18
that spoils all the juicy performance though :P
monochrom 2017-02-03 14:42:51
Worry about correctness before worrying about performance.
erisco 2017-02-03 14:42:53
wonder why that is the case... hm
erisco 2017-02-03 14:42:57
yes yes
jle` 2017-02-03 14:43:07
in this case it isn't obvious why
erisco 2017-02-03 14:43:10
but what do I tell all my friends
jle` 2017-02-03 14:43:25
but there are some cases where newtype obviously can't do
jle` 2017-02-03 14:43:39
newtype Showable = forall a. Show a => Showable a
monochrom 2017-02-03 14:43:44
But if you have an existential type that involves a type class, you will be carrying a dictionary around per value, exactly what OOP does with virtual tables. It is going to be an overhead.
jle` 2017-02-03 14:43:59
a value of type 'Showable' has to carry around the 'Show' typeclass dicitionary
jle` 2017-02-03 14:44:04
yeah, exactly what monochrom said
jle` 2017-02-03 14:44:37
so really, at an implementation level, it's like newtype Showable a = Showable (forall a. (ShowDict a, a))
jle` 2017-02-03 14:44:49
* newtype Showable
jle` 2017-02-03 14:44:59
so it doesn't hold *just* an 'a', it also holds the typeclass instance dictionary