Cooler 2017-02-21 01:46:31
it says the actual type of f is a
Cooler 2017-02-21 01:46:52
and so its not a function, but a can be a function type can't it?
Cooler 2017-02-21 01:47:02
a can be b -> c
Cooler 2017-02-21 01:50:00
cocreature, ^
BernhardPosselt 2017-02-21 01:51:46
why doesn't head simply return a Maybe?
BernhardPosselt 2017-02-21 01:51:56
instead of panicking when it encounters an empty list
Cooler 2017-02-21 01:52:42
why doesn't read do the same
merijn 2017-02-21 01:52:43
Two reasons: 1) historical mistake and 2) sometime that's what you need, for example "map head . group" is perfectly safe (because group doesn't return empty lists), but writing the same code with Maybe involved would be cumbersome
merijn 2017-02-21 01:53:00
Cooler: We have readMaybe since GHC 7.6!
merijn 2017-02-21 01:53:06
:t Text.Read.readMaybe
lambdabot 2017-02-21 01:53:09
Read a => String -> Maybe a
Cooler 2017-02-21 01:53:23
can you derive it?
jnj 2017-02-21 01:53:45
BernhardPosselt, there is also listToMaybe in Data.Maybe if you wish to avoid head.
BernhardPosselt 2017-02-21 01:53:54
ah right
quchen 2017-02-21 02:01:58
NonEmpty is much newer than group, but yes.
cocreature 2017-02-21 02:02:04
Cooler: it _can_ be a function, but if you make an "instance Applicative (Sum a)" you can't chose what a is. it has to work for any a
chocopuff 2017-02-21 02:03:02
I'm trying to use the System.Process module, I'm a bit confused about the typeclasses. I defined a function "test" by test :: String -> [String] -> IO GHC.IO.Exception.ExitCode
chocopuff 2017-02-21 02:03:17
test = rawProcess "ls" []
chocopuff 2017-02-21 02:03:45
I found the type of *rawSystem (sorry typo) and copied it verbatim, but ghc is giving me errors during compile
chocopuff 2017-02-21 02:03:59
saying the type could not be matched. am not sure what is going on
Cooler 2017-02-21 02:04:23
cocreature, right
mauke 2017-02-21 02:04:39
chocopuff: consider the following code: foo :: String -> Int; foo = length "abc"
mauke 2017-02-21 02:04:45
do you see a problem with that?
mauke 2017-02-21 02:06:32
(there are no wrong answers, I'm just trying to bisect the explanation space)
chocopuff 2017-02-21 02:06:47
mauke: isn't foo just type int?
mauke 2017-02-21 02:06:56
right
chocopuff 2017-02-21 02:07:14
mauke: I think, I'm getting there but unable to connect the dots yet
mauke 2017-02-21 02:07:36
what's the type of rawSystem?
chocopuff 2017-02-21 02:07:37
mauke: oh shoot! sorry, I forgot the modify the code
chocopuff 2017-02-21 02:07:47
I meant to write test x = rawProcess "ls" [x]
chocopuff 2017-02-21 02:08:11
mauke: rawSystem :: String -> [String] -> IO GHC.IO.Exception.ExitCode
chocopuff 2017-02-21 02:08:14
sorry about that
mauke 2017-02-21 02:08:17
what's the type of rawSystem "ls"?
chocopuff 2017-02-21 02:09:24
mauke: rawSystem "ls" :: [String] -> IO GHC.IO.Exception.ExitCode
chocopuff 2017-02-21 02:09:46
That's the currying taking place I believe
mauke 2017-02-21 02:09:51
correct
mauke 2017-02-21 02:10:16
then I'm not sure what's unclear
Cooler 2017-02-21 02:10:19
look the type of test x
mauke 2017-02-21 02:10:22
how many arguments does test take?
Cooler 2017-02-21 02:10:36
look at*
chocopuff 2017-02-21 02:12:30
mauke: I thought the error was saying the output was type IO GHC.IO.Exception.ExitCode
mauke 2017-02-21 02:12:56
what's the error message?
chocopuff 2017-02-21 02:13:31
will be back in a few minutes, going to try again
spatial 2017-02-21 02:15:37
Still have a question. Transform lists of data into GUI co-ordinate system and display. How ?
srhb 2017-02-21 02:16:23
spatial: Like a plot?
srhb 2017-02-21 02:16:28
Your question isn't very specific.
Cooler 2017-02-21 02:16:38
this book seems to imply that monads allow you to look at the result of previous computations
spatial 2017-02-21 02:16:42
A grid or board game.
Cooler 2017-02-21 02:16:53
but applicatives and functors don't?
srhb 2017-02-21 02:17:17
spatial: The answer will mostly depend on which toolkit you use to draw the image.
spatial 2017-02-21 02:17:36
http://stackoverflow.com/questions/41930307/linking-ocaml-record-with-its-gui-representation
spatial 2017-02-21 02:17:50
I asked a OCaml question there
srhb 2017-02-21 02:18:25
spatial: And?
spatial 2017-02-21 02:18:54
So there was a functional approach suggested.
spatial 2017-02-21 02:19:15
Trying to learn a Haskell way of doing it.
srhb 2017-02-21 02:19:59
spatial: Looks like it's basically the same approach.
srhb 2017-02-21 02:20:11
Or well, that would be possible.
chocopuff 2017-02-21 02:20:47
mauke: I understand now! thanks. managed to get it fixed
chocopuff 2017-02-21 02:21:08
mauke: partly was my carelessness and using String instead of [String] in definition
srhb 2017-02-21 02:21:24
spatial: Perhaps check out the gloss examples (the conway one, for instance)
chocopuff 2017-02-21 02:21:24
this is fun, thanks for your guidance
spatial 2017-02-21 02:21:42
Let me check.
srhb 2017-02-21 02:22:24
spatial: After that you can read the definition of simulate and decide if that looks like something you'd want to do.
spatial 2017-02-21 02:22:34
Don't want libraries.
mauke 2017-02-21 02:22:46
heh
srhb 2017-02-21 02:22:52
spatial: Eventually you will need one to put stuff on your screen.
Cooler 2017-02-21 02:22:53
can't applicatives and functors look at the result of previous computation?
spatial 2017-02-21 02:22:54
Maybe I will try the OCaml solution.
srhb 2017-02-21 02:23:01
spatial: Goes for that one as well.
spatial 2017-02-21 02:23:18
Right
mauke 2017-02-21 02:23:25
the ocaml solution uses the lablgtk library
srhb 2017-02-21 02:23:44
And if you were to reimplement that, you'd end up in imperative horror land anyway.
srhb 2017-02-21 02:23:55
Libraries can hide that for you.
srhb 2017-02-21 02:24:02
Keeps you sane. More or less. :-)
Cooler 2017-02-21 02:25:34
anyone?
srhb 2017-02-21 02:26:25
Cooler: What do you mean by "previous computation" ?
pavonia 2017-02-21 02:26:32
They can't look at the result of any other actions
Cooler 2017-02-21 02:30:06
srhb, i don't know thats whats it says in the book
Cooler 2017-02-21 02:32:20
we are basically talking about chaining function application
Cooler 2017-02-21 02:32:40
using <*>
Cooler 2017-02-21 02:34:07
> pure (+1) <*> (pure (*2) <*> pure 2)
lambdabot 2017-02-21 02:34:13
error:
lambdabot 2017-02-21 02:34:13
• Ambiguous type variables 'f0', 'b0' arising from a use of 'show_M19995...
lambdabot 2017-02-21 02:34:13
prevents the constraint '(Show (f0 b0))' from being solved.
Cooler 2017-02-21 02:34:39
weird it works in REPL
Cooler 2017-02-21 02:35:01
gives 5 as the result
Cooler 2017-02-21 02:35:38
> pure (+1) <*> (pure (*2) <*> pure 2 :: Maybe Int)
lambdabot 2017-02-21 02:35:44
Just 5
Cooler 2017-02-21 02:36:14
see the result does depend on previous computations
mauke 2017-02-21 02:36:33
what do you mean by "previous computation"?
Cooler 2017-02-21 02:36:48
mauke, that basically
mauke 2017-02-21 02:37:16
that's a definition up with which I shall not put
Cooler 2017-02-21 02:37:40
the result of the rest of chain depends on the result of the previous function applications
mauke 2017-02-21 02:38:30
> return (+1) `ap` (return (*2) `ap` return 2) :: Maybe Int
lambdabot 2017-02-21 02:38:35
Just 5
Cooler 2017-02-21 02:38:37
mauke, also its not what i mean by it, its what the book means
Cooler 2017-02-21 02:39:13
and i am not sure what definition they are using
t4nk800 2017-02-21 02:40:40
What is the syntax for multiple let expressions in a list comprehension?
mauke 2017-02-21 02:41:18
?
Cooler 2017-02-21 02:41:22
1. With the Maybe Applicative, each Maybe computation fails or succeeds
Cooler 2017-02-21 02:41:23
independently of each other. You're just lifting functions that
Cooler 2017-02-21 02:41:23
are also Just or Nothing over Maybe values.
Cooler 2017-02-21 02:41:23
2. With the Maybe Monad, computations contributing to the final result
Cooler 2017-02-21 02:41:23
can choose to return Nothing based on "previous" computations.
tdammers 2017-02-21 02:42:00
> [ (x, y) | x <- [1,2,3], y <- [4,5,6] ]
lambdabot 2017-02-21 02:42:08
mueval-core: Time limit exceeded
tdammers 2017-02-21 02:42:10
hehe
tdammers 2017-02-21 02:42:14
> [ (x, y) | x <- [1,2,3], y <- [4,5] ]
lambdabot 2017-02-21 02:42:20
[(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
tdammers 2017-02-21 02:42:31
t4nk800: ^ like this?
t4nk800 2017-02-21 02:42:36
what if i want to insert let expressions in the list comprehension?
mauke 2017-02-21 02:42:45
just ... do it?
tdammers 2017-02-21 02:43:05
> [ let pair = (x, y) in pair | x <- [1,2], y <- [4,5] ]
lambdabot 2017-02-21 02:43:12
mueval-core: Time limit exceeded
tdammers 2017-02-21 02:43:18
wat
athan 2017-02-21 02:44:13
that's a good find o-o