dmwit 2017-03-05 18:46:26
Alternately: it is the same as `(\a -> c $ d a) =<< b`.
buttons840 2017-03-05 18:46:30
Koterpillar: ok, now I see what you were saying about $ eating my bind
hololeap 2017-03-05 18:47:47
so it's passing the first value through many actions, but what if i want the end value passed to something else? and how could i drop out of the chain while still carrying that value?
jle` 2017-03-05 18:48:00
hello all
hololeap 2017-03-05 18:48:33
for instance somebody typing "exit" would drop out of the chain, but the state would then be written to a file
jle` 2017-03-05 18:48:42
how do i provide documentation for record accessors made from pattern synonyms?
dmwit 2017-03-05 18:48:49
hololeap: Don't use `repeat`.
buttons840 2017-03-05 18:49:20
style question: I have the one liner I wanted (I like to avoid do notation until i know how to write the code without it): `pure . Card . sortOn (\(Side n _) -> n) =<< shuffleM a` -- is this horrible? should I use do notation instead?
jle` 2017-03-05 18:49:48
`pure . f =<< x` is just fmap f x
jle` 2017-03-05 18:49:58
or f <$> x
jle` 2017-03-05 18:50:12
so `Card . sortOn f <$> shuffleM a`
buttons840 2017-03-05 18:51:24
jle`: i see, ty
jle` 2017-03-05 18:51:33
the ugly part is the lambda with pattern matching
jle` 2017-03-05 18:51:38
but if Side is a record, you can use the record accessor
buttons840 2017-03-05 18:52:08
it is not a record
buttons840 2017-03-05 18:52:57
i know lens would be nice here, but I don't really know it and these small anoyances haven't pushed me to learn it yet
jle` 2017-03-05 18:53:35
well
jle` 2017-03-05 18:53:43
lens itself doesn't really directly help
jle` 2017-03-05 18:54:04
in this case the lens library would give you TH to automatically generate accessors
jle` 2017-03-05 18:54:26
the actual concept of lenses isn't too useful here
buttons840 2017-03-05 18:54:40
lens would let me avoid writting out the lambda through, right?
buttons840 2017-03-05 18:54:57
(not that a small lambda is a huge burden)
jle` 2017-03-05 18:55:03
you can avoid writing out the lambda by writing a helper function
jle` 2017-03-05 18:55:10
getThing (Side n) = n
dmwit 2017-03-05 18:55:21
Am I the only one that things `\(Side n _) -> n` is perfectly readable?
jle` 2017-03-05 18:55:31
the lens *library* offers template haskell that lets you generate the accessor atuomatically
jle` 2017-03-05 18:55:42
but lenses themselves are orthogonal to the issue
buttons840 2017-03-05 18:55:43
true, if I write this lambda multiple times I will break it out into a named function
dmwit 2017-03-05 18:55:52
This does not need fifteen minutes of engineering.
jle` 2017-03-05 18:56:04
dmwit: it's not too bad, but i don't like that the eye jumps in different directions when reading it
jle` 2017-03-05 18:56:36
buttons840: so, lens itself doesn't really offer anything too useful here, and the lens library offers some TH that is very very marginally useful
jle` 2017-03-05 18:56:58
don't worry about it :)
buttons840 2017-03-05 18:57:47
ok, thanks for pointing out that i could use fmap -- that was a useful simplification
jle` 2017-03-05 18:59:31
buttons840: btw, if the type that Side is has the auto-derived Ord instance, sortOn (\(Side n _) -> n) should be somewhat-similar to just 'sort'
buttons840 2017-03-05 18:59:33
hmm, i was reaching for both Applicative and Monad methods, when I could have just used Functor, interesting
ski 2017-03-05 18:59:39
dmwit : not the only one
ski 2017-03-05 19:02:10
hololeap : you could make an `exit' "drop out of the chain", by using exceptions (by which i mean something like `Either'), or continuations (`Cont')
hololeap 2017-03-05 19:02:36
ski: i'm looking at ExceptT right now
dogweather 2017-03-05 19:15:34
I'm currently implementing a Year with newtype and a toYear function https://github.com/dogweather/nv-statutes-haskell/blob/master/src/Year.hs
c_wraith 2017-03-05 19:16:35
dogweather: yes, liquidhaskell is good for that.
c_wraith 2017-03-05 19:17:13
dogweather: liquidhaskell adds a type of subtyping called refinement types - you can add predicates about the values the type can take.
c_wraith 2017-03-05 19:17:46
dogweather: it uses an SMT solver to check the refinements, which means it can handle arithmetic predicates nearly automatically
Rotaerk 2017-03-05 19:44:27
huh, LH looks cool
c_wraith 2017-03-05 19:44:32
though I'd like to see a haskell-like language built from scratch around liquid types. I hear F* was built around refinement types, but that's more F#-like, and I don't know if it has a solver built in.