Search Haskell Channel Logs

Sunday, February 5, 2017

#haskell channel featuring qmm, lyxia, joneshf-laptop, lambdabot, opqdonut, Zemyla, and 10 others.

phadej 2017-02-05 06:45:13
qmm: you most likely want some of encode functions: http://hackage.haskell.org/package/text-1.2.2.1/docs/Data-Text-Encoding.html
phadej 2017-02-05 06:45:26
or https://hackage.haskell.org/package/utf8-string
qmm 2017-02-05 06:45:43
ah, thank you phadej
lyxia 2017-02-05 06:46:12
buglebudabey: the last two lines give the solution
lyxia 2017-02-05 06:46:26
buglebudabey: modify your stack.yml file
buglebudabey 2017-02-05 06:46:35
lyxia yeah i just did it but now i've run into another problem
buglebudabey 2017-02-05 06:46:45
lyxia Could not find module 'Distribution.Superdoc'
lyxia 2017-02-05 06:47:06
where is that error located
buglebudabey 2017-02-05 06:49:20
lyxia looks like where stack installed that missing extra dependency
joneshf-laptop 2017-02-05 06:56:38
I'm trying to follow along with this blog post locally: https://izbicki.me/blog/the-categorical-distributions-algebraic-structure It seems like it needs ghc 7.6. I have ghc 8.0.1 installed on my machine and stack only supports 7.8 and newer. Is there a non-intrusive way to run the code on my machine?
joneshf-laptop 2017-02-05 06:56:46
Maybe with nix or some such?
qmm 2017-02-05 06:58:42
phadej: is there a way to go from Text to Lazy Bytestring?
joneshf-laptop 2017-02-05 06:59:21
Or maybe `cabal new-build` might work?
drninjabatman 2017-02-05 06:59:31
hello, does anyone know why `retract` from the `free` package requires that the returned type be Monad and not Functor?
phadej 2017-02-05 06:59:42
qmm: strict text to lazy bytestring?
qmm 2017-02-05 07:00:17
or lazy text
qmm 2017-02-05 07:00:28
is data.text strict?
monochrom 2017-02-05 07:00:34
Yes.
phadej 2017-02-05 07:01:02
qmm: then there's also http://hackage.haskell.org/package/string-conversions-0.4.0.1/docs/Data-String-Conversions.html
qmm 2017-02-05 07:01:07
Data.Text.Lazy
phadej 2017-02-05 07:01:12
with http://hackage.haskell.org/package/string-conversions-0.4.0.1/docs/Data-String-Conversions-Monomorphic.html
phadej 2017-02-05 07:01:49
probably there are other solutions to this problem as well
lyxia 2017-02-05 07:01:51
drninjabatman: its implementation uses return and (>>=)
joneshf-laptop 2017-02-05 07:02:01
lambdabot, :t retract
lyxia 2017-02-05 07:02:03
drninjabatman: how would you write it otherwise
phadej 2017-02-05 07:02:04
(string-conversions is used in servant, that how I know about it)
joneshf-laptop 2017-02-05 07:02:05
:t retract
lambdabot 2017-02-05 07:02:08
error: Variable not in scope: retract
lyxia 2017-02-05 07:02:30
:t Control.Monad.Free.retract
lambdabot 2017-02-05 07:02:31
Monad f => Control.Monad.Free.Free f a -> f a
qmm 2017-02-05 07:02:46
that did it
Zemyla 2017-02-05 07:04:03
Okay, I have a thought about expressing regular expressions in Haskell.
phadej 2017-02-05 07:05:04
Zemyla: applicative?
Zemyla 2017-02-05 07:05:25
Regular expressions are basically Applicative parsers expressing a tree, yes.
phadej 2017-02-05 07:05:36
Zemyla: http://hackage.haskell.org/package/regex-applicative
Zemyla 2017-02-05 07:06:03
phadej: I saw that. But the way it's constructed seems inefficient, because it doesn't do any kind of minimization on the resultant parser.
Zemyla 2017-02-05 07:06:36
Also, regular expressions are closed under intersection and complement, neither of which this offers.
opqdonut 2017-02-05 07:06:57
neither do usual regexps
phadej 2017-02-05 07:07:06
Zemyla: intersections is hard when you have capture groups
Zemyla 2017-02-05 07:07:31
Actually, I know how I would do it.
phadej 2017-02-05 07:08:10
i.e. if you have capture groups you are in NFA world, not DFA
phadej 2017-02-05 07:09:39
but if you don't want to capture substrings, then minimising implementation may be faster
phadej 2017-02-05 07:10:23
https://github.com/phadej/tarzan/blob/master/src/Tarzan.hs
qmm 2017-02-05 07:11:12
which style is does the community like?
qmm 2017-02-05 07:11:16
buckets <- R.listBuckets c (Just ( encodeUtf8 (L.pack "default")))
qmm 2017-02-05 07:11:22
buckets <- R.listBuckets c (Just $ encodeUtf8 (L.pack "default"))
qmm 2017-02-05 07:11:28
buckets <- R.listBuckets c $ Just $ encodeUtf8 $ L.pack "default"
maerwald 2017-02-05 07:11:35
first world problems
phadej 2017-02-05 07:11:37
qmm: personally, consistent
qmm 2017-02-05 07:11:55
phadej: hm?
phadej 2017-02-05 07:12:10
qmm: if you use some style, use it consistently, but I don't care which
maerwald 2017-02-05 07:12:29
there are 3453 similar questions you could ask about style
qmm 2017-02-05 07:12:37
the second one example i suppose is inconsistent?
Zemyla 2017-02-05 07:12:39
phadej: Actually, I figured out how you can do capture groups with DFAs.
monochrom 2017-02-05 07:12:40
The beginner community likes the fully $ version. The learned community likes the fully () version.
qmm 2017-02-05 07:12:44
that's the typical style for me currently
qmm 2017-02-05 07:12:48
i just use what works :)
Tuplanolla 2017-02-05 07:12:53
This question comes up all the time though.
phadej 2017-02-05 07:13:00
Zemyla: even ambigious ones?
phadej 2017-02-05 07:13:12
Zemyla: i.e. "few" "many" difference
Zemyla 2017-02-05 07:13:23
Yes, seriously.
qmm 2017-02-05 07:13:27
Tuplanolla: you have a great point. i should crawl through the logs and look for previous conversations
phadej 2017-02-05 07:13:35
Zemyla: then you should write it up :)
Zemyla 2017-02-05 07:13:54
Well, I've only got kind of a skeleton of it so far.
Tuplanolla 2017-02-05 07:13:57
Actually monochrom already summarized it, qmm.
Tuplanolla 2017-02-05 07:14:50
Once you've seen primitive and higher-rank types, you'll realize how strange `$` really is and might start avoiding it.
Zemyla 2017-02-05 07:15:04
But I'm thinking that a state in a regex - DFA, NFA, or e-NFA - is represented by a profunctor, StateP t (where t is the token type).
qmm 2017-02-05 07:15:24
Tuplanolla: what do high rank types have to do with $
qmm 2017-02-05 07:15:30
if you don't mind me asking
maerwald 2017-02-05 07:15:52
I suggest you just keep on coding instead of worrying about such style crap :P
Zemyla 2017-02-05 07:16:14
A StateP t a b receives a value of type a, and a token of type t, and eventually produces a value of type b.
phadej 2017-02-05 07:16:16
qmm: there is a special case in type checker so runST $ do ... is accepted
qmm 2017-02-05 07:16:30
i kind of like the mixture of both parens and the $
boojinks 2017-02-05 07:16:54
the mix is the ugliest imho, would definitely go for the first option
phadej 2017-02-05 07:17:34
boojinks: but how about `map (partiallyApplied foo) $ bar xs`
maerwald 2017-02-05 07:18:02
1$ for the style question jar
drninjabatman 2017-02-05 07:18:05
lyxia: it's just that `retract . liftF = id` but `liftF` takes functor as an argument and it seems a bit strange
ertes 2017-02-05 07:18:36
the problem i had earlier was not related to nix at all… there was a major LD_PRELOAD hack in place that interfered with nix
drninjabatman 2017-02-05 07:18:39
lyxia: it's not a proble, I ended up using `iter`, I just found it a bit odd
boojinks 2017-02-05 07:18:44
phadej: can't say I'm a fan :)
phadej 2017-02-05 07:19:04
boojinks: well, that's where the $ breaks
Zemyla 2017-02-05 07:19:14
I know that a StateP with epsilon transitions would be represented as StateP { accepts :: Maybe (a -> b), eTransitions :: [exists c. (a -> c, StateP tc b)], transitions :: t -> [exists c. (a -> c, StateP t c b)] }
phadej 2017-02-05 07:19:16
tbh, I actually doesn't have an opinion
Tuplanolla 2017-02-05 07:20:16
> I# $ 42#
lambdabot 2017-02-05 07:20:19
error:
lambdabot 2017-02-05 07:20:19
• Data constructor not in scope: I# :: GHC.Prim.Int# -> t
lambdabot 2017-02-05 07:20:19
• Perhaps you meant 'In' (imported from Lambdabot.Plugin.Haskell.Eval.Tr...
Zemyla 2017-02-05 07:20:24
And the regex would be represented as newtype Regex t a = Regex { unRegex :: forall r x. StateP t (a, r) x -> StateP t r x }
phadej 2017-02-05 07:20:51
isn't exists c. (a -> c, StateP t c b) same as StateP t a b
phadej 2017-02-05 07:21:03
why you need the existential there?
phadej 2017-02-05 07:22:16
Zemyla: how the intersection would look like?
Zemyla 2017-02-05 07:24:18
phadej: Because I actually was planning to have it return a value of type exists c. (a -> c, Key c), which would index into a keyed map which returns a StateP t c b.
sternmull 2017-02-05 07:24:20
can anyone suggest a good editor or even an IDE? Currently i am using emacs with haskell-mode... but i am not really happy with it.
phadej 2017-02-05 07:24:36
Zemyla: ah
phadej 2017-02-05 07:24:38
like how ((aa)*|(aaa)*)+ would work
Zemyla 2017-02-05 07:24:55
This way, whatever takes the state list could minimize them.
Zemyla 2017-02-05 07:26:01
But the reason for the Regex type is its input is the final state, which wants a value of type (a, r) and produces an x, and returns the initial state, which only requires an r.
Zemyla 2017-02-05 07:32:52
@let newtype RegexP p a = RegexP { unRegexP :: forall r x. p (a, r) x -> p r x } -- phadej
lambdabot 2017-02-05 07:32:54
Defined.
Zemyla 2017-02-05 07:33:05
@let instance Profunctor p => Functor (ApP p) where fmap f (ApP m) = ApP $ m . lmap (\(a, r) -> (f a, r))
lambdabot 2017-02-05 07:33:06
.L.hs:186:35: error: Not in scope: type constructor or class 'ApP'
lambdabot 2017-02-05 07:33:06
lambdabot 2017-02-05 07:33:06
.L.hs:187:17: error: Not in scope: data constructor 'ApP'
Zemyla 2017-02-05 07:33:25
@let instance Profunctor p => Functor (RegexP p) where fmap f (RegexP m) = RegexP $ m . lmap (\(a, r) -> (f a, r))
lambdabot 2017-02-05 07:33:26
Defined.
joneshf-laptop 2017-02-05 07:33:33
sternmull, what things make you unhappy about haskell-mode?
Zemyla 2017-02-05 07:34:03
@let instance Profunctor p => Applicative (RegexP p) where { pure a = RegexP $ lmap ((,) a); RegexP mf <*> RegexP ma = RegexP $ \p -> mf $ ma $ lmap (\(a, (f, r)) -> (f a, r)) p }
lambdabot 2017-02-05 07:34:05
Defined.
joneshf-laptop 2017-02-05 07:34:09
sternmull, alternatively, what things would make you happy about haskell-mode
sm 2017-02-05 07:34:22
sternmull: I like IDEA and haskforce or intellij-haskell
sternmull 2017-02-05 07:35:31
joneshf-laptop: Autocompletion does not work and i can't see why. The documentation does not help with this, it tells me that it works out of the box. And the "interactive-mode" does some stupid things i don't understand (types lambda in my buffer and nothing else...). So i think i should look for alternatives.
sm 2017-02-05 07:35:34
also, have you tried intero in emacs
maerwald 2017-02-05 07:35:43
some people (I think Cale) also use Sublime
maerwald 2017-02-05 07:35:54
I personally tried leksah once, but I don't like the internal editor
maerwald 2017-02-05 07:35:57
great as an IDE though
joneshf-laptop 2017-02-05 07:37:49
sternmull, I see. Thats pretty bad.
sternmull 2017-02-05 07:38:41
ok, i will check out intellij. I also think to give atom a try.