lyxia 2017-02-07 01:46:11
Foo Bar is the constructor Foo applied to Bar. (Foo, Bar) is a tuple of Foo and Bar.
systadmin 2017-02-07 01:46:52
> length (Foo, Bar)
lambdabot 2017-02-07 01:46:55
error: Data constructor not in scope: Fooerror:
lambdabot 2017-02-07 01:46:55
• Data constructor not in scope: Bar
lambdabot 2017-02-07 01:46:55
• Perhaps you meant one of these:
noan 2017-02-07 01:47:25
can't be that then.. type: Foo (Bar Baz) is just a chain of constructors then?
Reisen 2017-02-07 01:48:45
Would it look less strange to you if it were slightly more descriptive names? I.E, Array (Maybe Unit)?
Ferdirand 2017-02-07 01:50:39
we don't even know if you are talking about expressions or types
noan 2017-02-07 01:50:46
Ferdirand, type.
noan 2017-02-07 01:52:40
It's App (Key User) where App is https://hastebin.com/olehumurit.hs User is a simple data type, and Key is something off persistent I'm still looking for in a moment
BernhardPosselt 2017-02-07 01:53:58
got this: ifFunc True val _ = val
BernhardPosselt 2017-02-07 01:53:58
ifFunc _ _ val = val
BernhardPosselt 2017-02-07 01:54:05
ifFunc (1 < 3) "correct" "incorrect"
BernhardPosselt 2017-02-07 01:54:10
spits out "incorrect"
BernhardPosselt 2017-02-07 01:54:18
why doesnt it match True?
Ferdirand 2017-02-07 01:55:08
BernhardPosselt: works for me
BernhardPosselt 2017-02-07 01:55:14
ghci btw
lyxia 2017-02-07 01:55:26
> let ifFunc True val _ = val ; ifFunc _ _ val = val in ifFunc (1 < 3) "correct" "incorrect"
Ferdirand 2017-02-07 01:55:28
maybe you shadowed ifFunc ?
lambdabot 2017-02-07 01:55:29
"correct"
Ferdirand 2017-02-07 01:55:40
did you give the two clauses in separate lets ?
BernhardPosselt 2017-02-07 01:55:56
i pasted in my two lines
BernhardPosselt 2017-02-07 01:56:04
and then pasted in ifFunc (1 < 3) "correct" "incorrect"
BernhardPosselt 2017-02-07 01:56:07
and executed it
lyxia 2017-02-07 01:56:11
if you did this in ghci then you wrote two functions
lyxia 2017-02-07 01:56:17
and the second one shadows the first
BernhardPosselt 2017-02-07 01:56:23
i see
BernhardPosselt 2017-02-07 01:56:35
is there a neat way to combine it without let?
Ferdirand 2017-02-07 01:57:17
stick in a file ?
BernhardPosselt 2017-02-07 01:57:24
;D
lyxia 2017-02-07 01:57:33
in ghci you can use :{ :} to wrap a multiline definition
BernhardPosselt 2017-02-07 01:57:52
ok, seems you can also do ifFunc True val _ = val ; ifFunc _ _ val = val
BernhardPosselt 2017-02-07 02:07:01
is there a way to show the type/type class of Maybe?
BernhardPosselt 2017-02-07 02:07:04
in ghci
BernhardPosselt 2017-02-07 02:07:08
:t Nothing works
lambdabot 2017-02-07 02:07:10
error:
lambdabot 2017-02-07 02:07:10
• Couldn't match expected type 't0 -> t'
lambdabot 2017-02-07 02:07:10
with actual type 'Maybe a0'
BernhardPosselt 2017-02-07 02:07:12
:t Maybe doesnt
lambdabot 2017-02-07 02:07:14
error:
lambdabot 2017-02-07 02:07:14
• Data constructor not in scope: Maybe :: t0 -> t
lambdabot 2017-02-07 02:07:14
• Perhaps you meant variable 'maybe' (imported from Data.Maybe)
BernhardPosselt 2017-02-07 02:08:00
ah
BernhardPosselt 2017-02-07 02:08:02
:info Maybe
Axman6 2017-02-07 02:08:08
BernhardPosselt: try :info (and maybe also :kind)
BernhardPosselt 2017-02-07 02:15:55
what do you use for returning a result that can hold a value or an error? Either seems very low level
BernhardPosselt 2017-02-07 02:16:04
e.g. in Rust you can use Result https://doc.rust-lang.org/std/result/
BernhardPosselt 2017-02-07 02:16:20
which allows you to map over results if no error is present
BernhardPosselt 2017-02-07 02:16:36
or execute further code if no error is present
hpc 2017-02-07 02:16:48
Either is that thing
hpc 2017-02-07 02:17:24
if you want to add short-circuiting with an error value to some other sort of computation, consider ErrorT
hpc 2017-02-07 02:17:32
(or ExceptT, i can never remember the difference between them)
opqdonut 2017-02-07 02:17:51
https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html
BernhardPosselt 2017-02-07 02:17:58
thanks!
phadej 2017-02-07 02:19:51
hpc: ErrorT is deprecated (it restricts what kind of errors can be thrown)
hpc 2017-02-07 02:21:28
ah, that's it then
absence 2017-02-07 02:23:19
@let import Data.List.NonEmpty
lambdabot 2017-02-07 02:23:20
Defined.
absence 2017-02-07 02:23:25
:t \f fz (a :| as) -> foldl' f (fz a) as
lambdabot 2017-02-07 02:23:27
(b -> a -> b) -> (a -> b) -> NonEmpty a -> b
absence 2017-02-07 02:23:39
is there something like this in the libraries?
opqdonut 2017-02-07 02:25:19
well there's the Foldable NonEmpty instance
opqdonut 2017-02-07 02:25:24
but that's not quite what you want?
Aravindh 2017-02-07 02:25:54
Can someone tell me a streaming library in haskell? like akka streams for scala
absence 2017-02-07 02:26:17
opqdonut: it doesn't quite seem to fit, but maybe i haven't thought it through properly
absence 2017-02-07 02:28:03
opqdonut: the Foldable instance requires a constant "zero" value, but i don't have a way to make one
opqdonut 2017-02-07 02:28:51
absence: foldl1?
magthe 2017-02-07 02:29:12
Any intero users in here? I'm trying out intero in spacemacs and get an error when compiling a "setup-shim": http://lpaste.net/352128
quchen 2017-02-07 02:29:24
Aravindh: pipes or conduit are our standard streaming libs
Aravindh 2017-02-07 02:29:58
@quchen: Thank you
lambdabot 2017-02-07 02:29:58
Unknown command, try @list
Xnuk 2017-02-07 02:30:19
@list
lambdabot 2017-02-07 02:30:19
What module? Try @listmodules for some ideas.
Xnuk 2017-02-07 02:30:30
@listmodules
lambdabot 2017-02-07 02:30:30
activity base bf check compose dice dict djinn dummy elite eval filter free fresh haddock help hoogle instances irc karma localtime metar more oeis offlineRC pl pointful poll pretty quote search
lambdabot 2017-02-07 02:30:30
slap source spell system tell ticker todo topic type undo unlambda unmtl version where
absence 2017-02-07 02:31:12
opqdonut: it's "f a -> a" rather than "f a -> b"
opqdonut 2017-02-07 02:31:49
absence: ah yes because it doesn't have the fz, that makes sense
opqdonut 2017-02-07 02:31:56
absence: I think you'll have to define your own
Aravindh 2017-02-07 02:32:47
quchen: Thank You
absence 2017-02-07 02:34:48
opqdonut: i seem to run into similar problems quite often when working with NonEmpty. makes me feel like i'm missing something, or that it's less useful than i imagine :)
BernhardPosselt 2017-02-07 02:35:17
why doesnt Monad Maybe define return https://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#line-665
BernhardPosselt 2017-02-07 02:35:29
can it be derived automatically from the Monad defintition?
BernhardPosselt 2017-02-07 02:35:51
e.g. only Just matches the type in return (a -> m a)
phadej 2017-02-07 02:36:37
BernhardPosselt: lookup 'Monad m where' i.e the definition of Monad class
phadej 2017-02-07 02:36:47
it says 'return = pure'
phadej 2017-02-07 02:37:27
i.e. you can omit return definition starting from base-4.8 / GHC 7.10 IIRC
BernhardPosselt 2017-02-07 02:37:28
ah
BernhardPosselt 2017-02-07 02:37:33
default implementation?
phadej 2017-02-07 02:37:47
yes
BernhardPosselt 2017-02-07 02:37:55
ty
systadmin 2017-02-07 02:40:15
Just a quick question, what does the `IO ()` type do?
merijn 2017-02-07 02:40:56
systadmin: Depends on what you mean by "what does X type do"?
phadej 2017-02-07 02:41:06
hard question indeed
merijn 2017-02-07 02:41:10
systadmin: Can you elaborate what you want to know?
systadmin 2017-02-07 02:41:31
Like the `IO` used in this piece of code? http://sprunge.us/VEXO?haskell
m4lvin 2017-02-07 02:41:36
systadmin: something of type IO () can do any IO operations but only return something of the empty type, so in some sense nothing.
Xe 2017-02-07 02:41:52
systadmin: IO is a type that orders execution of its functions and data, haskell is normally unordered
merijn 2017-02-07 02:41:53
systadmin: I mean, type don't really do anything
merijn 2017-02-07 02:42:09
Xe: That's...not right
merijn 2017-02-07 02:42:20
Types don't "order" anything
Denommus 2017-02-07 02:42:46
we could try to understand what he meant instead of what he said
Xe 2017-02-07 02:42:58
no, but the runtime and compiler do use the RealWorld tokens to order execution
merijn 2017-02-07 02:42:59
And IO certainly doesn't turn Haskell from unordered to ordered execution. Especially considering (GHC) haskell has a pretty well-defined order
merijn 2017-02-07 02:43:18
Denommus: I'm awaiting clarification, because it's not enough for me to guess what he is really asking
m4lvin 2017-02-07 02:43:29
^this.
barrucadu 2017-02-07 02:43:54
nmattia: Unfortunately I don't, no
merijn 2017-02-07 02:44:01
Xe: The runtime doesn't use RealWorld at all and you're better off forgetting it's existence, because it's really not a helpful fact to know. Especially considering the unfortunately chosen name