Search Haskell Channel Logs

Saturday, February 25, 2017

#haskell channel featuring hexagoxel, dramforever, lyxia, Aku, Welkin, ertes, and 5 others.

Phillemann 2017-02-25 03:52:16
What's the easiest/shortest way to execute an IO action if I have a value inside a Maybe and "return ()" if the Maybe is Nothing?
Phillemann 2017-02-25 03:53:18
I get a bit confused by Maybe being Monad, Foldable and Traversable. ;)
dramforever 2017-02-25 03:53:18
:t for
lambdabot 2017-02-25 03:53:20
(Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
dramforever 2017-02-25 03:53:33
Phillemann: You're right about Traversable actually
Phillemann 2017-02-25 03:53:35
Ah, exactly, thanks.
bollu 2017-02-25 03:53:39
dramforever: my god, I had never considered using the traversable instance
dramforever 2017-02-25 03:53:43
oh wait you don't need the result?
dramforever 2017-02-25 03:53:46
:t for_
bollu 2017-02-25 03:53:48
:t for_
lambdabot 2017-02-25 03:53:48
(Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
dramforever 2017-02-25 03:53:49
That's a Foldable thing
lambdabot 2017-02-25 03:53:50
(Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
bollu 2017-02-25 03:53:59
dramforever: that is glorious
bollu 2017-02-25 03:54:08
dramforever: wait, can you derive traversable on any inductive type?
dramforever 2017-02-25 03:54:28
Sorta, if it's obviously traversable
dramforever 2017-02-25 03:54:41
obviously as to, well, GHC's deriving mechanism can figure it out
bollu 2017-02-25 03:54:49
dramforever: what makes something "obviously traversable"?
bollu 2017-02-25 03:55:04
actually don't answer that
bollu 2017-02-25 03:55:07
I want to figure it out
dramforever 2017-02-25 03:55:57
SPOILER: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#deriving-traversable-instances
dramforever 2017-02-25 03:57:00
Actually... Go check it. For *these* things, checking the docs is way better than trail and error.
dramforever 2017-02-25 03:58:17
And yeah, glorious Haskell. Python may amaze you with new libraries you can download. Haskell amazes you with things you thought you knew.
Aku 2017-02-25 04:02:39
bollu: up there?
hexagoxel 2017-02-25 04:14:42
AndreasK: may i ask what os you ran frag on?
AndreasK 2017-02-25 04:14:54
hexagoxel: Window
AndreasK 2017-02-25 04:14:55
s
hexagoxel 2017-02-25 04:15:51
ah, i should try that; perhaps linux glut is at fault.
Welkin 2017-02-25 04:16:57
nvidia is at fault
Welkin 2017-02-25 04:17:00
and ati/amd
hexagoxel 2017-02-25 04:18:35
Welkin: but other engines run smoothly.
AndreasK 2017-02-25 04:19:00
hexagoxel: What fps do you get/how bad is the lag?
AndreasK 2017-02-25 04:19:49
It doesn't feel completely snappy for me either, but wouldn't call it unbearable
hexagoxel 2017-02-25 04:20:03
it displays 60 fps, but i am pretty sure it is not accurate/there is a lot of jitter involved.
hexagoxel 2017-02-25 04:31:41
the main non-subjective issue with input is that it seems to "drop" both keyboard and mouse events: keys easily get stuck, and when you move mouse quick-to-left, slow-to-right, the camera ends in a different spot (and no, i have no acceleration whatsoever).
ph88^ 2017-02-25 04:32:48
is there a function that takes a Maybe and a function. When value is Nothing yield Nothing, but if is Just a then apply function to a and return that ?
hexagoxel 2017-02-25 04:32:59
:t maybe
lambdabot 2017-02-25 04:33:02
b -> (a -> b) -> Maybe a -> b
hexagoxel 2017-02-25 04:33:19
:t fmap
lambdabot 2017-02-25 04:33:21
Functor f => (a -> b) -> f a -> f b
ph88^ 2017-02-25 04:34:28
oh it's fmap o_O
ph88^ 2017-02-25 04:34:32
> fmap (\x -> x + 1) Nothing
lambdabot 2017-02-25 04:34:34
Nothing
AndreasK 2017-02-25 04:36:53
hexagoxel: The slow on direction/fast the other is expected if you have mouse acceleration enabled (on windows thats on by default iirc). Not sure if thats the case for you
hexagoxel 2017-02-25 04:39:27
let me repeat: i am certain that i have exactly 0 mouse acceleration on the os-level.
ertes 2017-02-25 04:39:38
ph88^: (>>=)
ertes 2017-02-25 04:39:48
or yes, fmap
AndreasK 2017-02-25 04:40:36
hexagoxel: I only ran around a few seconds and at least there i got not stuck keys. But dropping events sounds like a sensible explanation
ph88^ 2017-02-25 04:41:17
hexagoxel, i'm trying to use fmap to replace a case statement on a Maybe, can you tell what i'm doing wrong here? https://bpaste.net/show/0459c8ca12d6
Welkin 2017-02-25 04:41:34
ph88^: case expression
Welkin 2017-02-25 04:41:39
it's not a statement
ph88^ 2017-02-25 04:43:02
oh ok
hexagoxel 2017-02-25 04:43:13
ph88^: your `go` returns a `Just`, i.e. a Maybe
hexagoxel 2017-02-25 04:43:31
but fmap :: (a -> b) -> Maybe a -> Maybe b
ph88^ 2017-02-25 04:44:04
ooh
hexagoxel 2017-02-25 04:44:22
with (=<<) it would be (a -> Maybe b) -> Maybe a -> Maybe b
ph88^ 2017-02-25 04:44:25
ye ok, i'm being silly :|
ertes 2017-02-25 04:44:44
> (isqrt 0, isqrt 1, isqrt 2, isqrt 3)
lambdabot 2017-02-25 04:44:46
(Just 0,Just 1,Nothing,Nothing)
ertes 2017-02-25 04:44:58
@let ifourthRoot x = isqrt x >>= isqrt
lyxia 2017-02-25 04:44:59
ph88^: remove Just line 15
lambdabot 2017-02-25 04:45:00
Defined.
hexagoxel 2017-02-25 04:45:02
(and you can write `go Refl = f x`)
ertes 2017-02-25 04:45:12
> ifourthRoot 256
lambdabot 2017-02-25 04:46:24
Just 4
ph88^ 2017-02-25 04:47:31
just refactoring lyxia's code xD
hexagoxel 2017-02-25 04:49:45
(also, example f = fmap f . cast , isn't it?)
hexagoxel 2017-02-25 04:50:25
:t \f -> fmap f . cast
lambdabot 2017-02-25 04:50:25
(Typeable a1, Typeable a) => (a -> b) -> a1 -> Maybe b
Welkin 2017-02-25 04:50:25
:t cast
lambdabot 2017-02-25 04:50:25
(Typeable b, Typeable a) => a -> Maybe b
ph88^ 2017-02-25 04:50:25
what's cast ?
Welkin 2017-02-25 04:50:25
never seen it
Welkin 2017-02-25 04:50:25
@hoogle cast
lambdabot 2017-02-25 04:50:25
Data.Typeable cast :: forall a b . (Typeable a, Typeable b) => a -> Maybe b
lambdabot 2017-02-25 04:50:25
Data.Bson cast :: (Val a, Monad m) => Value -> m a
lambdabot 2017-02-25 04:50:25
Control.Distributed.Process.ManagedProcess.Client cast :: (Addressable a, Serializable m) => a -> m -> Process ()
hexagoxel 2017-02-25 04:50:25
it is the function right above `eqT` :p
Welkin 2017-02-25 04:50:25
http://hackage.haskell.org/package/base-4.9.1.0/docs/Data-Typeable.html#v:cast