doomlord 2017-02-28 15:47:45
one thing that bugged me about haskell was the lack of 'dot' accessor syntax (dot is used for function composition?) .. do they have an operator like that these days. "object.field" I seem to remember being told haskell concention is always to write expressions 'right to left' (e.g. $ operator) instead of 'left to right' (the threading macro in clojure)
Koterpillar 2017-02-28 15:48:18
there's & if you want it
marchelzo 2017-02-28 15:48:37
you mean like for accessing fields of records?
Koterpillar 2017-02-28 15:48:48
:t (&)
lambdabot 2017-02-28 15:48:51
a -> (a -> b) -> b
marchelzo 2017-02-28 15:49:07
you can use lens for that and then you can just use regular . to compose
Koterpillar 2017-02-28 15:49:24
so if you have data Data = { foo :: Int, bar :: String }, then this works: data & foo
Koterpillar 2017-02-28 15:49:33
and with lenses, data & foo.bar.baz
Koterpillar 2017-02-28 15:49:48
or even without lenses
tibbe 2017-02-28 15:50:14
I'm trying to use ConstraintKinds to alias a MonadReader: type EnvM m n = MonadReader (Env n) m
tibbe 2017-02-28 15:50:19
where Env is a concrete data type
tibbe 2017-02-28 15:50:29
but I get: Non type-variable argument in the constraint: MonadReader (Env n) m
tibbe 2017-02-28 15:50:36
why isn't this working? :)
tibbe 2017-02-28 15:52:32
I'm just trying to create a new, more specialized version of the MonadReader type class (i.e. with the environment fixed)
robkennedy 2017-02-28 15:56:07
@hoogle (b -> c -> t b c) -> (a -> Maybe b) -> (a -> Maybe c) -> (a -> Maybe (t b c))
lambdabot 2017-02-28 15:56:10
Control.Monad.HT liftJoin4 :: Monad m => (a -> b -> c -> d -> m e) -> m a -> m b -> m c -> m d -> m e
lambdabot 2017-02-28 15:56:11
Control.Concatenative biSpM :: Monad m => (a -> m c) -> (b -> m d) -> (c -> d -> m e) -> a -> b -> m e
lambdabot 2017-02-28 15:56:11
Control.Concatenative triM :: Monad m => (a -> m b) -> (a -> m c) -> (a -> m d) -> (b -> c -> d -> m e) -> a -> m e
pikajude 2017-02-28 15:56:50
robkennedy: try liftA2
robkennedy 2017-02-28 15:57:03
:t liftA2
lambdabot 2017-02-28 15:57:05
Applicative f => (a -> b -> c) -> f a -> f b -> f c
pikajude 2017-02-28 15:57:18
> liftA2 (,) (Just 3) (just 4)
lambdabot 2017-02-28 15:57:21
error:
lambdabot 2017-02-28 15:57:21
• Variable not in scope: just :: Integer -> Maybe b
lambdabot 2017-02-28 15:57:21
• Perhaps you meant data constructor 'Just' (imported from Data.Maybe)
pikajude 2017-02-28 15:57:21
> liftA2 (,) (Just 3) (Just 4)
pikajude 2017-02-28 15:57:24
whoops
lambdabot 2017-02-28 15:57:25
Just (3,4)
suica 2017-02-28 15:58:52
is lpaste.net down? related to S3 issues?
robkennedy 2017-02-28 15:59:02
:t liftA2 (,) listToMaybe (\l -> if null l then Nothing else Just (sum l)) [1..5]
lambdabot 2017-02-28 15:59:05
(Num t, Enum t) => (Maybe t, Maybe t)
robkennedy 2017-02-28 15:59:41
pikajude: I'm hoping to join them
threshold 2017-02-28 15:59:48
I am learning about the fixed point of a functor, Fix, by reading http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html
pikajude 2017-02-28 15:59:48
what's in them
robkennedy 2017-02-28 16:00:46
Well if I have two functions I'm hoping to get Nothing if failure happens in either.
threshold 2017-02-28 16:01:05
Given data Toy b next = Output b next | Bell next | Done and data Fix f = Fix (f (Fix f)) What is going on here? Fix (Output 'A' (Fix Done)) :: Fix (Toy Char)
dfeuer 2017-02-28 16:04:47
*headshake*. containers is full of unresolved GitHub issues, and I absolutely don't have time to work through most of them soon. (Which isn't to say I haven't been working on containers; just a lot of work all around.)
hpc 2017-02-28 16:05:14
threshold: when used with Fix, next = Fix (Toy b)
hpc 2017-02-28 16:05:17
so it's like writing
hpc 2017-02-28 16:05:27
data Toy b = Output b (Toy b) | Bell (Toy b) | Done
hpc 2017-02-28 16:06:20
to do it with Fix, you need to add the Fix data constructor in a few places
hpc 2017-02-28 16:07:50
threshold: how much have you done with fix at the value level?
EvanR 2017-02-28 16:08:12
i waiting for the article on "you could have invented free monad monad monad algebras"
pikajude 2017-02-28 16:08:31
the "you could have invented this" free monad
hpc 2017-02-28 16:09:20
i can't wait for the retrospective on haskell
hpc 2017-02-28 16:09:26
"'you could have invented lens' and other falsehoods"
hpc 2017-02-28 16:10:11
threshold: anyhoo, any understanding you are able to carry over from fix will also apply to Fix
hpc 2017-02-28 16:10:15
which can make it easier
threshold 2017-02-28 16:11:40
hpc: Today is the first day that I've heard of a fixed point, so I have very little experience with fix
raynold 2017-02-28 16:14:43
ahh it's a wonderful day
threshold 2017-02-28 16:24:59
Maybe a better question is how does fix work?
threshold 2017-02-28 16:25:27
@src fix
lambdabot 2017-02-28 16:25:28
fix f = let x = f x in x
barrucadu 2017-02-28 16:29:33
Perhaps a more readable definition if `fix f = f (fix f)`
barrucadu 2017-02-28 16:29:34
*is
threshold 2017-02-28 16:30:25
barrucadu: That is still mind boggling
threshold 2017-02-28 16:30:42
How do you use it?
threshold 2017-02-28 16:32:10
https://en.wikipedia.org/wiki/Fixed_point_(mathematics) should be useful in understanding?
barrucadu 2017-02-28 16:33:11
`fix` lets you do recursion without giving a name to your recursive function
barrucadu 2017-02-28 16:33:32
> fix (\go x -> if x == 0 then 1 else x * go (x-1)) 5 -- factorial
lambdabot 2017-02-28 16:33:34
120
nshepperd 2017-02-28 16:39:25
threshold: fix returns the 'least' fixed point of the function, in the domain theory sense
Squarism 2017-02-28 16:40:22
does it sound sane to "send a channel over a channel" ? =D
benzrf 2017-02-28 16:41:16
threshold: `fix f' is a fixpoint of f in a very boring way, by definition
benzrf 2017-02-28 16:41:39
threshold: `fix f' expands to `f (fix f)' by definition, so naturally `fix f = f (fix f)'
benzrf 2017-02-28 16:41:50
then `fix f' is a fixpoint, in a very cheating-y way
benzrf 2017-02-28 16:42:25
intuitively, if you have an infinitely deeply nested list of applications of f, like `f (f (f (f (f ...))))', then adding another f won't hurt
nshepperd 2017-02-28 16:42:39
threshold: I guess http://stackoverflow.com/a/4787577 is the thing to read
benzrf 2017-02-28 16:42:53
but note that this is only useful if you have lazy evaluation - with strict evaluation, this is always an infinite loop
benzrf 2017-02-28 16:43:14
`fix f' is quite often still an infinite loop in haskell, but not always:
benzrf 2017-02-28 16:43:17
> fix (+1)
lambdabot 2017-02-28 16:43:23
mueval-core: Time limit exceeded
benzrf 2017-02-28 16:43:24
> fix (1:)
lambdabot 2017-02-28 16:43:28
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1...
benzrf 2017-02-28 16:43:47
`1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + ...' is undefined, of course, but `1:1:1:1:1:1:1:...' makes sense!
pacak 2017-02-28 16:43:55
> fix error
lambdabot 2017-02-28 16:43:59
"*Exception: *Exception: *Exception: *Exception: *Exception: *Exception: *Ex...
benzrf 2017-02-28 16:44:03
:}
pacak 2017-02-28 16:44:08
Exceptions all the way down!
benzrf 2017-02-28 16:44:27
@let me = const (text "Some things are unfixable.")
lambdabot 2017-02-28 16:44:31
Defined.
benzrf 2017-02-28 16:44:31
> fix me
lambdabot 2017-02-28 16:44:35
Some things are unfixable.
nshepperd 2017-02-28 16:44:46
:{