ertes 2017-02-08 09:45:10
tlahtoani: i think ph88 meant to say that you shouldn't shy away from extensions… everybody uses them
ph88 2017-02-08 09:45:12
tlahtoani, because there are a lot of great extensions you don't really want to do without. Like OverloadStrings if you want to work with Text instead of linked list of characters
ph88 2017-02-08 09:45:38
ertes, yes that's exactly what i meant :P
tlahtoani 2017-02-08 09:45:38
In C compiler extensions are usually bad, I assume this is not the case in Haskell
ertes 2017-02-08 09:45:55
tlahtoani: standard haskell is usable, but extensions ramp up its expressivity massively
ph88 2017-02-08 09:46:07
it feels utterly weird to start a new language and then already having to enable some non-standard compiler option (the extension) .. but this is just the case
Tuplanolla 2017-02-08 09:46:08
Would there be life without `NumDecimals`?
ertes 2017-02-08 09:46:10
tlahtoani: it's a cultural difference
ertes 2017-02-08 09:46:29
would there be life without RankNTypes?
EvanR 2017-02-08 09:46:36
ph88: technically non standard
EvanR 2017-02-08 09:46:52
but what they dont know is ghc is the defacto standard
ph88 2017-02-08 09:47:00
tlahtoani, newer versions of GHC will include some extensions by default i'm sure .. it's also a more kind of preference way of programming rather than a non-standard way (although SOME extensions are quite exotic)
tlahtoani 2017-02-08 09:47:16
Like?
AWizzArd 2017-02-08 09:47:21
In ghci, when I have an expression E I can use :t to see the type of E. Is there a way to ask for the type of a subexpression within E?
EvanR 2017-02-08 09:47:21
some extensions are kind of necessary
reactormonk 2017-02-08 09:47:37
How can i derive Data for a higher-kinded type, e.g. https://hackage.haskell.org/package/uri-bytestring-0.2.2.1/docs/URI-ByteString.html#t:URIRef
EvanR 2017-02-08 09:47:47
FlexibleInstances FlexibleContexts OverloadedStrings GADTs RankNTypes
ertes 2017-02-08 09:47:53
AWizzArd: give that subexpression a partial type signature: (SubExp :: _)
EvanR 2017-02-08 09:48:06
ScopedTypeVariables
ph88 2017-02-08 09:48:10
tlahtoani, exotic to me would be DataKinds .. i saw it mentioned but never used it .. other people might say it's not that exotic and can probably give you an example of an even more obscure one
EvanR 2017-02-08 09:48:40
exotic, UndecidableInstances
ph88 2017-02-08 09:48:57
that one i actually do use xD
EvanR 2017-02-08 09:49:03
considered harmful, IncoherentInstances
Tuplanolla 2017-02-08 09:49:44
Don't forget all the little guys like `NegativeLiterals` or `BinaryLiterals`.
ertes 2017-02-08 09:49:53
AWizzArd: or even just an obviously wrong type signature… then GHC will tell you how terrible you are for lying about its type
ertes 2017-02-08 09:50:08
:t replicate (4 :: ()) 'a'
lambdabot 2017-02-08 09:50:09
error:
lambdabot 2017-02-08 09:50:09
• Couldn't match expected type 'Int' with actual type '()'
lambdabot 2017-02-08 09:50:09
• In the first argument of 'replicate', namely '(4 :: ())'
EvanR 2017-02-08 09:50:11
i want negative literals in idris
max3 2017-02-08 09:50:23
geekosaur, http://pastebin.com/y5WD8fab
AWizzArd 2017-02-08 09:50:24
ertes: Okay great, will try that.
CuriousErnestBro 2017-02-08 09:50:25
why does the compiler give a warning with a tab character?
reactormonk 2017-02-08 09:50:29
http://lpaste.net/352242
geekosaur 2017-02-08 09:50:52
because different programs treat tabs as having different widths
ertes 2017-02-08 09:51:01
AWizzArd: alternatively turn the subexpression into a hole, then GHC will give you a lot more information, including variables and their types that are in scope for the subexpression
geekosaur 2017-02-08 09:51:05
and this is deadly in an indentation sensitive language
ertes 2017-02-08 09:51:15
:t replicate _ 'a'
lambdabot 2017-02-08 09:51:17
error:
lambdabot 2017-02-08 09:51:17
• Found hole: _ :: Int
lambdabot 2017-02-08 09:51:17
• In the first argument of 'replicate', namely '_'
ph88 2017-02-08 09:51:17
reactormonk, did you derive Data for Absolute separately ?
reactormonk 2017-02-08 09:51:26
ph88, as you see
reactormonk 2017-02-08 09:51:35
What's the proper way?
ph88 2017-02-08 09:51:56
reactormonk, i don't see because where is "data Absolute = " ?
ondraa 2017-02-08 09:52:02
Hello. I have a FilePath, set OverloadedStrings and I want to use function which takes Path (http://hackage.haskell.org/package/libmpd-0.9.0.6/docs/Network-MPD.html#t:Path), which is an instance of IsString. But it does not typecheck. Can it be because MPD does not export the IsString instance?
reactormonk 2017-02-08 09:52:06
data Absolute deriving(Typeable)
reactormonk 2017-02-08 09:52:11
ph88, sorry, it's a bit further down.
geekosaur 2017-02-08 09:52:12
max3, you'd want to use `stack exec happy` for the check, and in general I think you need someone who knows stack internals
CuriousErnestBro 2017-02-08 09:52:26
geekosaur, so I should make my text editor turn those tabs into spaces?
ph88 2017-02-08 09:52:29
reactormonk, try data Absolute deriving (Data)
max3 2017-02-08 09:52:33
geekosaur, that's successful as well
geekosaur 2017-02-08 09:52:39
(note that stack will not use a happy from your normal PATH by default because stack does not control that)
max3 2017-02-08 09:52:41
geekosaur, okay i'll go to #stack
max3 2017-02-08 09:52:56
geekosaur, happy is in both paths
geekosaur 2017-02-08 09:53:21
I mean stack will not use a happy from outside of its own storage
reactormonk 2017-02-08 09:53:22
ph88, can't make an instance, needs at least one constructor :-(
geekosaur 2017-02-08 09:53:34
which the stack exec won;t show. "stack paths" might
AWizzArd 2017-02-08 09:53:39
ertes: how can one turn subexpressions into a hole?
reactormonk 2017-02-08 09:53:45
Ah, standalone
ph88 2017-02-08 09:53:46
reactormonk, ok i guess that is already an indication of some underlying problem ..
geekosaur 2017-02-08 09:53:55
CuriousErnestBro, that's the usual solution, yes. (also the one used with python which has the same issue)
ph88 2017-02-08 09:54:02
reactormonk, did you enable this extensions to have types without data constructor ?
reactormonk 2017-02-08 09:54:17
ph88, nope, works this way now. Back to the initial problem.
ph88 2017-02-08 09:54:35
so you add deriving Data to Absolute ?
reactormonk 2017-02-08 09:54:41
Yeah
reactormonk 2017-02-08 09:56:00
brb
ph88 2017-02-08 09:56:09
reactormonk, maybe try instance Data a => Data (URIRef a)
ph88 2017-02-08 09:56:21
not that i know about this stuff, just a guess :D
ph88 2017-02-08 09:57:59
anyone know a good place to get this book ? http://www.cs.nott.ac.uk/~pszgmh/pih.html
ertes 2017-02-08 09:58:28
AWizzArd: you have to replace them by an identifier that starts with _
ertes 2017-02-08 09:58:52
AWizzArd: not terribly convenient, but usually your kill buffer is good enough =)
AWizzArd 2017-02-08 10:00:00
good
geekosaur 2017-02-08 10:02:21
hm, can you also turn on type wildcards and wrap the subexpression in ( ... :: _) ?
ertes 2017-02-08 10:03:31
geekosaur: yeah, that was my earlier suggestion
ertes 2017-02-08 10:03:52
typed holes are a bit more useful though, because they show the scope as well
ph88 2017-02-08 10:07:41
travv0, tlahtoani look what i just found https://www.futurelearn.com/courses/functional-programming-haskell free online course .. and there are also other courses online for free
travv0 2017-02-08 10:08:57
ph88: registered interest, thanks
max3 2017-02-08 10:12:40
this is newb question: what is the debugging workflow? i come from imperative land and i'm having trouble since i can't stick print statement in random places
max3 2017-02-08 10:12:50
let alone breakpoints
tlahtoani 2017-02-08 10:12:50
I don't do courses
tlahtoani 2017-02-08 10:12:56
I just like print books
ph88 2017-02-08 10:13:04
max3, you can put Debug.Trace.trace statements in random places
ph88 2017-02-08 10:13:34
max3, you put breakpoints in ghci with :break
Tuplanolla 2017-02-08 10:14:12
You'll also find that around here people prefer to split things into simple testable functions instead of debugging, max3.
max3 2017-02-08 10:14:24
Tuplanolla, yes that's what i was thinking
ph88 2017-02-08 10:14:44
i debug first and split when debugging gets too hard :P
max3 2017-02-08 10:16:00
is it crazy to ever except the same sort of debugging experience i have with pycharm?
max3 2017-02-08 10:16:24
or chrome dev tools?
max3 2017-02-08 10:16:34
where you can set a breakpoint and fiddle with everything in scope?
ph88 2017-02-08 10:17:07
i would have the same expectations ^^
Sonolin 2017-02-08 10:17:28
that would be nice to have a GUI interface to breakpoints, but I'm not aware of anything available for Haskell
bwe 2017-02-08 10:17:28
Yes, to ask for benchmarks might not be the wisest question. However, I want to get a rough idea how Haskell levels against Go.
ph88 2017-02-08 10:17:28
maybe emacs has some ghci intergration which can do it
Sonolin 2017-02-08 10:17:32
yea that'd be where I check first ^^
ph88 2017-02-08 10:17:39
bwe, i think pretty much the same
ph88 2017-02-08 10:18:12
travv0, tlahtoani max3 https://commercialhaskell.github.io/intero/
Sonolin 2017-02-08 10:18:20
unrelated, but I found profiling with GHC a breeze (and made a huge diff in performance for my use case)
max3 2017-02-08 10:18:28
i'm allergic to emacs
ph88 2017-02-08 10:18:37
:D
max3 2017-02-08 10:18:41
is there an intero for vim :)
ph88 2017-02-08 10:18:58
max3, special for you http://www.stephendiehl.com/posts/vim_2016.html
bwe 2017-02-08 10:19:05
ph88: So Haskell really performs as fast as Go which is similar to C?
benzrf 2017-02-08 10:19:29
go is similar to C? isnt it garbage collected?
ph88 2017-02-08 10:19:30
bwe, yeah
benzrf 2017-02-08 10:19:34
oh... i guess that only adds delays, not necessarily slows down everything in the language
max3 2017-02-08 10:19:38
ph88, thanks
bwe 2017-02-08 10:19:55
ph88: Are you writing from experience or by referring to third parties experiences?
benzrf 2017-02-08 10:19:57
er, intermittent delays, separate from the cost of just executing stuff
ph88 2017-02-08 10:19:59
benzrf, it's similar yes when you compare it with perl or so that is 500x slower lol
ph88 2017-02-08 10:20:26
bwe, experiences i've read and also benchmarks i saw
benzrf 2017-02-08 10:20:29
bwe: haskell performance is variable - it dpeends on the code you write
ph88 2017-02-08 10:20:47
bwe, there are stories that some programs beat C programs in performance
Sonolin 2017-02-08 10:20:55
yea, I've found well written haskell code to be *very* fast
bwe 2017-02-08 10:20:58
benzrf: Which sounds realistic.
benzrf 2017-02-08 10:21:30
bwe: haskell is static enough that you can do crazy good optimization, but it's high-level enough that plenty of easy code has semantics that don't really correspond to a fast low-level solution
benzrf 2017-02-08 10:21:32
kinda
ph88 2017-02-08 10:21:36
bwe, but with haskell you can optimize the shit out of it ... i mean the compiler is already really good but then you can really tweak it low level as well and also use many cores
chpatrick 2017-02-08 10:22:01
bwe: it's possible but not by default
benzrf 2017-02-08 10:22:18
bwe: so some subset of haskell code can be reliably translated into c-tier performance, but plenty can't
ertes 2017-02-08 10:22:32
is there a variant of MutVar# for unlifted types?
ertes 2017-02-08 10:22:38
like: MutVar# RealWorld Int#
benzrf 2017-02-08 10:22:39
if you really need high perf, you have to know what you're doing, and a little bit about the low-level stuff
benzrf 2017-02-08 10:23:11
i'd say it's pretty fast in general, though - just maybe not c level
ph88 2017-02-08 10:23:28
bwe, if you do a webserver you can also have a lot of connections just like Go
chpatrick 2017-02-08 10:23:47
bwe: although it's pretty easy to write C++ inline if you really need to
bwe 2017-02-08 10:23:48
benzrf: What do you mean by a 'fast low-level solution`?
benzrf 2017-02-08 10:24:26
chpatrick: lol
ertes 2017-02-08 10:25:04
bwe: it all boils down to predictability… haskell is not slower than C (it can beat C in some cases, especially when concurrency is involved), but *predicting* the performance/efficiency of haskell code takes experience
ph88 2017-02-08 10:25:10
bwe, i guess he means that if you reach a certain level of abstraction that there are several ways to implement it low-level .. so there is no 1-to-1 relation there
chpatrick 2017-02-08 10:25:28
I'd say "haskell isn't slower than C" is a bit disingenous
chpatrick 2017-02-08 10:25:40
it's possible to make it as fast but it's usually not very idiomatic/readable code
benzrf 2017-02-08 10:25:59
bwe: i mean something fast you might write in C
tlahtoani 2017-02-08 10:26:07
Speed isn't the only thing that matters
chpatrick 2017-02-08 10:26:13
it is for some things
tlahtoani 2017-02-08 10:26:31
Then you probably wouldn't be using Haskell
ertes 2017-02-08 10:26:40
chpatrick: i beg to differ… it's usually the idiomatic haskell code that gets close to C performance, but one needs to realise that e.g. lists aren't idiomatic for everything
monochrom 2017-02-08 10:26:43
You can't discuss speed as a simple boolean "fast vs slow".
fsestini 2017-02-08 10:26:56
hi. can anybody help me understand why a declaration like f = show . read cannot have inferred type (Read a, Show a) => String -> String?
chpatrick 2017-02-08 10:27:00
ertes: well super hand-written basic recursive stuff is very fast
chpatrick 2017-02-08 10:27:17
but for real-world stuff I'd consider list and monad combinators more idiomatic
chpatrick 2017-02-08 10:27:19
but then it won't be fast
benzrf 2017-02-08 10:27:24
fsestini: it's.... the DREADED MONOMORPHISM RESTRICTION
benzrf 2017-02-08 10:27:26
probably
bwe 2017-02-08 10:27:26
benzrf: Where the question arises C or Go?
fsestini 2017-02-08 10:27:39
benzrf: with that disabled, i should have said
benzrf 2017-02-08 10:27:43
oh, hah
ertes 2017-02-08 10:27:52
chpatrick: something along the lines of (foldr _f _z (unfoldr _g _s0)) is very fast, too and totally idiomatic
bwe 2017-02-08 10:27:54
geekosaur: We all know this to be a purely psychological question.
benzrf 2017-02-08 10:27:57
fsestini: is this top-level or is it bound in a where or let clause
reactormonk 2017-02-08 10:28:08
ph88, works, but warns about missing methods.
fsestini 2017-02-08 10:28:08
benzrf: top level
bwe 2017-02-08 10:28:15
geekosaur: it's like 'who has the shiniest car' issue.
lyxia 2017-02-08 10:28:15
fsestini: the problem is that a is ambiguous, and there is no way to disambiguate it.
chpatrick 2017-02-08 10:28:23
also often the speed depends on getting lucky with the inliner
chpatrick 2017-02-08 10:28:28
which is totally voodoo
benzrf 2017-02-08 10:28:38
lyxia: oh, fuck
ph88 2017-02-08 10:28:41
reactormonk, :D :D :D
benzrf 2017-02-08 10:28:45
i misread it as read . show
fsestini 2017-02-08 10:28:46
lyxia: but why can't it just be lest there in the type?
benzrf 2017-02-08 10:28:48
haha
fsestini 2017-02-08 10:28:53
*left
benzrf 2017-02-08 10:29:08
fsestini: if you turn on type applications, you may be able to get away with it
fsestini 2017-02-08 10:29:12
i mean, shouldn't be a problem of the caller how to disambiguate it?
benzrf 2017-02-08 10:29:13
although you'll have to allow ambiguous types, i think
chpatrick 2017-02-08 10:29:19
we have a largish computer vision project where the architectural parts are in haskell and the parts that do a lot of number crunching are in C++
chpatrick 2017-02-08 10:29:23
that works pretty well with inline-c
fsestini 2017-02-08 10:29:30
benzrf: i think so
ertes 2017-02-08 10:29:30
chpatrick: that's exactly what i mean by predictability… you can make haskell code fast without sacrificing its elegance (too much), but it takes a lot of experience
lyxia 2017-02-08 10:29:37
fsestini: yes but why write a function you can't call? (pre-GHC 8)
ertes 2017-02-08 10:30:02
and by fast i don't necessarily mean "as fast as C", just close enough that you don't get PHP levels of performance
monochrom 2017-02-08 10:30:08
fsestini: OK, I am a caller. How do I disambiguate? What exact code should I write? Let's say I want "Int".
bwe 2017-02-08 10:30:15
tlahtoani: So if speed is the question, what should my choice be?
chpatrick 2017-02-08 10:30:26
we're talking about as fast as C though
chpatrick 2017-02-08 10:30:36
which usually takes some dirty tricks
chpatrick 2017-02-08 10:30:40
or you know, cbits
monochrom 2017-02-08 10:31:06
In fact I don't think TypeApplication helps me (the caller) either.
geekosaur 2017-02-08 10:31:25
fsestini, the problem here is that between the read and the show it has to pick some type. what type it picks has an effect on what instances of Read and Show used. this type *is not visible* outside of the definition of f; you cannot control it. you also cannot determine it at runtime based on the string you feed it.
geekosaur 2017-02-08 10:31:33
so no, type applications wouldn't help either
benzrf 2017-02-08 10:31:36
monochrom: what about somethign like
monochrom 2017-02-08 10:31:49
f @ Int? No, clearly not.
fsestini 2017-02-08 10:31:58
geekosaur: but why not said that the function has type (Read a, Show a) => String -> String
benzrf 2017-02-08 10:32:02
foo :: forall a. (Show a, Read a) => String -> String; foo = show @ a . read @ a
fsestini 2017-02-08 10:32:06
*say
geekosaur 2017-02-08 10:32:17
fsestini, ok fine, let's say this
benzrf 2017-02-08 10:32:30
@let foo :: forall a. (Show a, Read a) => String -> String; foo = show @ a . read @ a
lambdabot 2017-02-08 10:32:30
Parse failed: Parse error in expression: show@a
benzrf 2017-02-08 10:32:34
:|
geekosaur 2017-02-08 10:32:37
what is the type iof the value passted between read and show?
geekosaur 2017-02-08 10:32:48
remember: what string this accepts is determined by that tyoe
monochrom 2017-02-08 10:32:51
benzrf: Does that work? Have you tried? I'm OK with going GHC 8.
geekosaur 2017-02-08 10:32:51
*type
geekosaur 2017-02-08 10:33:16
there are ways to force this to work and those ways will mean the function accepts exactly one string: "()"
geekosaur 2017-02-08 10:33:30
is this useful to you?
benzrf 2017-02-08 10:33:39
monochrom: it works
monochrom 2017-02-08 10:33:46
Oh that's neat.
benzrf 2017-02-08 10:34:03
@let {-# LANGUAGE TypeApplications #-}
lambdabot 2017-02-08 10:34:05
Defined.
benzrf 2017-02-08 10:34:11
@let foo :: forall a. (Show a, Read a) => String -> String; foo = show @ a . read @ a
lambdabot 2017-02-08 10:34:11
Parse failed: Parse error in expression: show@a
benzrf 2017-02-08 10:34:14
:\
Tuplanolla 2017-02-08 10:34:20
@let --
geekosaur 2017-02-08 10:34:22
ghc is failing because it cannot by default assign that inner type. if you use extended defaulting to force it, you get something utterly useless, for essentially the same reason: it cannot do anything useful without that inner type
lambdabot 2017-02-08 10:34:23
Defined.
monochrom 2017-02-08 10:34:29
yeah I'll have to try on my own computer
lyxia 2017-02-08 10:34:39
http://lpaste.net/352245
benzrf 2017-02-08 10:34:41
monochrom: u also need to turn on scopedtypevariables, of course
fsestini 2017-02-08 10:34:49
geekosaur: but why does it have to default it?
fsestini 2017-02-08 10:34:59
can't a just be left universally quantified?
geekosaur 2017-02-08 10:35:01
fsestini, because that is how it picks *which* read and show
benzrf 2017-02-08 10:35:02
fsestini: it works in ghc 8 when you manually apply stuff and use scoped type variables
benzrf 2017-02-08 10:35:30
bbl
geekosaur 2017-02-08 10:35:30
they are not magic, nor do they accept any type and pick one based on the string (this is not something Haskell does)
monochrom 2017-02-08 10:35:38
I go low-tech and use ExplicitForall :)
lyxia 2017-02-08 10:35:40
I didn't see the problem inside the definition of f earlier.
geekosaur 2017-02-08 10:36:10
they muust have a type *at compile time*, and which one you use determines which `read` and `show` are used (by selecting instances of `Read` and `Show`)
monochrom 2017-02-08 10:36:27
Oh yikes I really need ScopedTypeVariables
geekosaur 2017-02-08 10:36:32
but I suspect you are hanging up on: "dynamic languages will pick one based on the string I give it".
geekosaur 2017-02-08 10:36:40
Haskell is not a dynamically typd language
geekosaur 2017-02-08 10:36:56
> read "5"
lambdabot 2017-02-08 10:36:59
*Exception: Prelude.read: no parse
monochrom 2017-02-08 10:37:04
I don't think even dynamic languages are that magical.
fsestini 2017-02-08 10:37:12
geekosaur: i'm not thinking about that
artstart 2017-02-08 10:37:24
hi. haskell noob here. is there a function for the filter and then map pattern e.g: map f . filter pred
monochrom 2017-02-08 10:37:24
I mean unless they foresake user-defined types.
artstart 2017-02-08 10:37:25
?
fsestini 2017-02-08 10:37:48
i just don't see the difference between the type of show . read and some other C a => t, where t contains a
Tuplanolla 2017-02-08 10:38:14
Well, `foldr`, but that's perhaps a bit too general, artstart.
fsestini 2017-02-08 10:38:28
but maybe there are some details of the typeclass resolution that i'm missing
monochrom 2017-02-08 10:38:37
benzrf: I am still getting an ambiguous-type error.
lyxia 2017-02-08 10:39:11
:t mapMaybe -- artstart
lambdabot 2017-02-08 10:39:13
(a -> Maybe b) -> [a] -> [b]
monochrom 2017-02-08 10:39:34
But I'm doing everything at the ghci prompt. Maybe I should try a file.
lyxia 2017-02-08 10:39:49
monochrom: http://lpaste.net/352245
monochrom 2017-02-08 10:40:14
Oh God AllowAmbiguousTypes
lyxia 2017-02-08 10:40:48
Best extension.
geekosaur 2017-02-08 10:40:53
fsestini, how do you have it pick an a for (show :: Show a => a -> String) . (read :: Read a => String -> a) ?
geekosaur 2017-02-08 10:41:26
more precisely, how would *you* go about picking that a?
monochrom 2017-02-08 10:41:32
fsestini: But "String -> String" doesn't contain "a".
artstart 2017-02-08 10:41:37
lyxia: thanks
fsestini 2017-02-08 10:41:49
geekosaur: the same way i do for read :: Read a => String -> a, i don't. or better, i do when a gets specialized
geekosaur 2017-02-08 10:41:58
you cannot specialize it
fsestini 2017-02-08 10:42:09
geekosaur: the fact that a cannot be specialized should not prevent me from defining that function
geekosaur 2017-02-08 10:42:11
that is precisely the point
monochrom 2017-02-08 10:42:23
Is this an exercise of "the computer should do what I mean"?
geekosaur 2017-02-08 10:42:27
fsestini, so you want a function that has no idea what it does?
monochrom 2017-02-08 10:42:40
Because I don't believe in DWIM. I believe in WDYM.
fsestini 2017-02-08 10:43:17
geekosaur: it's just that i think it should type check anyway
geekosaur 2017-02-08 10:44:19
... I'm sorry, that is nonsense.
geekosaur 2017-02-08 10:44:34
you cannot say what that does, why should it be allowed to typecheck?
geekosaur 2017-02-08 10:44:56
what it does is *defined* by the choice of a. the compiler is telling you this when it refuses to typecheck