jchia_1 2017-02-17 20:45:49
EvanR: I only do run-time testing in other languages. However, isn't the exception mechanism in haskell doing something like run-time testing of type equality?
jle` 2017-02-17 20:45:49
yeah, this question sort of exists on three levels
jle` 2017-02-17 20:46:24
(1) how is (:~:) useful?; (2) why is knowing that it has a Category instance usefu?; (3) why is it being a Category instance useful
EvanR 2017-02-17 20:46:36
exceptions are dynamically typed indeed
EvanR 2017-02-17 20:46:44
its kind of embarassing
jle` 2017-02-17 20:46:45
for (2), it's that you can use a unified API, so you know that you can use id/(.) instead of whatever arcane name the normal API functions have
jle` 2017-02-17 20:47:02
for (3), it's because you can use Category-polymorphic functions like (<<<) on it
jle` 2017-02-17 20:47:06
for (1), that is beyond the scope of this discussion
jchia_1 2017-02-17 20:47:16
EvanR: I don't know how it could be better, though. Practically, an exception could be anything
jchia_1 2017-02-17 20:47:29
you could get an exception for all kinds of reasons
EvanR 2017-02-17 20:47:34
"_ could be anything" should sound like a red flag to you
jchia_1 2017-02-17 20:47:48
EvanR: Isn't that what happens when you write a real-world program?
EvanR 2017-02-17 20:48:00
and after getting into haskell "i dont know how it could be done better" has become the worse justification for anything
jchia_1 2017-02-17 20:48:11
the program can fail for all kinds of reasons outside its control
EvanR 2017-02-17 20:48:19
because i regularly am blown away by new solutions
jchia_1 2017-02-17 20:48:32
EvanR: enlighten me
EvanR 2017-02-17 20:49:18
i have a paper here which extends the idea of extensible records (products) with its dual: extensible variants (coproducts)
EvanR 2017-02-17 20:50:00
so you can use (co-)row polymorphism to talk about only some of the potential cases of a variant
EvanR 2017-02-17 20:50:14
which are identified by arbitrary labels
EvanR 2017-02-17 20:50:34
the end result is type safe and checked at compile time
jchia_1 2017-02-17 20:53:20
EvanR: what's the paper title?
EvanR 2017-02-17 20:53:46
https://www.microsoft.com/en-us/research/publication/extensible-records-with-scoped-labels/
jchia_1 2017-02-17 20:57:27
jle`, EvanR: Thanks for answering my questions.
jle` 2017-02-17 20:58:09
jchia_1: no problem! the answers might not be too satisfying at this level, but that's sort of a universal consensus about the Category typeclass itself
jle` 2017-02-17 21:02:25
jchia_1: oh, and just like for the common misconception of the 'IO Monad', the *usefulness* of kleisli arrows and of type equality and of functions doesn't come from thje fact that tehy are Category instance
jle` 2017-02-17 21:02:26
s
jle` 2017-02-17 21:02:38
just like that the usefulness of IO doesn't come from the fact that it's a Monad instance
jle` 2017-02-17 21:02:58
the usefulness of the types comes from the types themselves. Category, Monad, etc. only provide a convenient universal API, and also a way to write polymorphic functions
jchia_1 2017-02-17 21:08:14
jle`: OK
`Guest05 2017-02-17 21:08:32
Binary is not lazy enough
jchia_1 2017-02-17 21:14:59
jle`: OK
jchia_1 2017-02-17 21:15:13
so i just have to open my eyes and see the patterns?
jchia_1 2017-02-17 21:15:27
to see the opportunities for abstraction?
jchia_1 2017-02-17 21:15:46
is there a method for this?
MarcelineVQ 2017-02-17 21:15:56
when you get tired of repeating yourself things tend to pop up on their own
MarcelineVQ 2017-02-17 21:16:18
in my fairly limited experience
jchia_1 2017-02-17 21:17:33
MarcelineVQ: That's also partly my experience with templates in C++.
ertes 2017-02-17 21:22:36
i have a type class with a single type argument that carries no significance except to select the instance, where the associated types are the actual significant types: class C s where type A s; type B s; type C s; …
ertes 2017-02-17 21:23:19
any of the associated types selects the instance uniquely and determines all others… what i'd like is to get rid of the 's' argument, because it's redundant
ertes 2017-02-17 21:23:52
i tried with a nullary type class and injective type families, but then GHC insists that i can only have a single instance anyway
lyxia 2017-02-17 21:24:05
class C a b c | a -> b c, b -> a c, c -> a b where ...?
ertes 2017-02-17 21:24:45
lyxia: i'd like to avoid that, because it would make me spell out all the types in every context
lyxia 2017-02-17 21:25:29
Why?
ertes 2017-02-17 21:25:29
any other options?
ertes 2017-02-17 21:25:57
lyxia: myFunction :: (C a b c d e f) => …
lyxia 2017-02-17 21:26:33
oh.
ertes 2017-02-17 21:27:03
also single-letter names aren't really appropriate here, which makes it even worse
ertes 2017-02-17 21:27:51
guess i'll go with the dummy type then
Cooler 2017-02-17 21:32:24
does negate have an instance of functor?
jle` 2017-02-17 21:33:52
Cooler: types are functor instances
jle` 2017-02-17 21:34:07
negate is not a type
jle` 2017-02-17 21:34:30
but, functions have a Functor instance. or, ((->) r) has a Functor instance
Cooler 2017-02-17 21:34:53
wait
Cooler 2017-02-17 21:35:10
(->) has functor instance?
narasca 2017-02-17 21:35:16
only ((->) a)
jle` 2017-02-17 21:35:33
`((->) r)` has a functor instance, for any r
Cooler 2017-02-17 21:35:52
isn't the kind of (->) r :: *?
jle` 2017-02-17 21:35:56
you can read ((->) r) like (r ->), if sections were allowed for typeclass instances
Wizek_ 2017-02-17 21:35:59
hello. I'm in a situation in some of my projects that the import list in some of my files are growing rather longer than I'd like. About 20-40 lines. And many of these are redundant between my modules. So initially I though to use the trick I saw Yesod use: have a file named Imports.hs that does only a single thing: import the common modules and re-export them. Then I realized that this way I won't be able to distinguish my import
Wizek_ 2017-02-17 21:35:59
based on module qualification, e.g. Set.fromList vs Map.fromList to name a common one. Then another idea came: Couldn't I use the C preprocessor for this? I just did a quick test and amazingly writing `#include "Imports.hs"` seems to work! So at this point I decided to ask around: Is there any well-known/potential drawbacks of doing this? I don't remember it being done in any Haskell source I've read.
jle` 2017-02-17 21:36:02
Cooler: not quite
jle` 2017-02-17 21:36:09
what do you think the kind of (->) is?
Cooler 2017-02-17 21:36:20
* -> *?
Cooler 2017-02-17 21:36:33
no wait
Cooler 2017-02-17 21:36:44
* -> * -> * ?
Cooler 2017-02-17 21:37:00
takes 2 types and gives you a function type
Lokathor 2017-02-17 21:37:03
A functor is like any type that can hold a value without the structure needing to change if the value changes, and a function can be thought of as matching that
Lokathor 2017-02-17 21:37:23
well, a partly applied function that is
jle` 2017-02-17 21:38:07
Cooler: yeah
jle` 2017-02-17 21:38:13
so (->) :: * -> * -> *
jle` 2017-02-17 21:38:17
but, say, (->) Int :: * -> *
jle` 2017-02-17 21:38:20
(->) Bool :: * -> *
Cooler 2017-02-17 21:38:51
why does (->) r have a functor instance?
Lokathor 2017-02-17 21:39:20
well if it's a law abiding instance, you'd always prefer to have more instances than less
jle` 2017-02-17 21:40:13
Cooler: are you asking about a fundamental mathematical reason, or about why the instance exists in Haskell?
jle` 2017-02-17 21:40:23
the instance is in haskell because it's a pretty useful one
jle` 2017-02-17 21:40:34
so it would be kind of silly to not have it
dmj` 2017-02-17 21:40:35
Wizek: I'd keep cpp usage to a minimum if possible, and probably for things external to your own logic, like package versions, os's, compiler versions, etc.
Wizek_ 2017-02-17 21:42:18
dmj`, Do you mean that some of those variables may influence of what gets spliced in?
Cooler 2017-02-17 21:43:35
jle`, is the fmap instance for (->) r just function composition .?
dmj` 2017-02-17 21:44:04
Wizek: If you have a lot of imports, it sounds like a refactor might be a better choice, as opposed to reaching for cpp
jle` 2017-02-17 21:44:14
Cooler: interesting idea
jle` 2017-02-17 21:44:24
does fmap = (.) typecheck? does it follow the laws?