<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 _2_5 26 27  
28 29 30 31
00:00 lambda-11235 joined
00:00 infinity0_ joined
00:00 infinity0_ joined
00:00 bydo joined
00:00 bollu joined
00:01 rameerez joined
00:01 atk joined
00:03 infinity0 joined
00:03 Welkin joined
00:05 sgronblo joined
00:06 infinity0 joined
00:06 SolitaryCypher joined
00:07 wroathe joined
00:08 drcode joined
00:08 infinity0 joined
00:08 MP2E joined
00:10 codesoup joined
00:10 Aruro joined
00:11 infinity0 joined
00:13 ystael joined
00:14 infinity0 joined
00:14 leobloom joined
00:15 dysfun joined
00:15 theDon joined
00:16 tomboy64 joined
00:18 <AWizzArd> Anyone here who tried Selenium with Haskell?
00:18 wroathe joined
00:18 centril joined
00:18 sgronblo_ joined
00:18 mizu_no_oto joined
00:18 JoshS joined
00:19 tzh joined
00:19 fxrs joined
00:19 soniku joined
00:19 <AWizzArd> I was giving the hs-webdriver a try and tried out that little example at https://github.com/kallisti-dev/hs-webdriver/blob/master/examples/readme-example-beginner.md but get an UnknownCommand exception.
00:21 jabesed joined
00:22 sleffy joined
00:22 <wizwizwizwiz> haven't tried it,... i find in general if you try to use software that isn't well used, you end up with problems like the one you are describing
00:23 JeanCarloMachado joined
00:23 <jabesed> does using DataKinds, imply that any declaration "data X = ... " defines both a kind X and a type X?
00:23 <Welkin> that is my understanding, but I haven't used it before
00:23 <johnw> that's my understanding; not sure if the compiler needs to see you use it as a kind to do the work
00:23 <jabesed> or is there some way to specify data kind / that type definition
00:24 <jabesed> that results in a lot of junk...
00:24 whaletechno joined
00:24 <Welkin> it's okay if it defines kinds that you don't use
00:24 <Welkin> you just don't use them
00:24 <MarcelineVQ> it is both, where it's used will determine which you meant
00:24 systemfault joined
00:25 homesitter joined
00:25 <jabesed> Welkin: sure, likewise for types, but one may accidentally use them, leading to more complicated errors than necessary
00:26 <AWizzArd> wizwizwizwiz: although this library seems as if someone has put lots of effort into it. Well written tutorial and readme, commits since many years, even recent ones.
00:26 kotangen1 joined
00:27 <jabesed> another question... is there some de facto standard these days for extensible records?
00:27 lambdafan joined
00:27 wroathe joined
00:27 dolio joined
00:27 <jabesed> it appears some applications use heterogeneous lists
00:28 <jabesed> I wanted to defined some ASTs for a language that may be extended
00:28 <homesitter> let's give it a try : https://gammastorm.github.io/robot.html
00:29 <jabesed> so as of right now I was just considering parameterizing them (and use that parameter for possible extensions)
00:29 mizu_no_oto joined
00:29 rameerez joined
00:29 SoupEvil joined
00:30 <jabesed> (for no extension I'd use Void as parameter)
00:30 al-damiri joined
00:31 Taslem joined
00:32 monarch_ joined
00:33 <monarch_> when using Persistent, how can I set another entity's implicitly generated Primary Key Id as a Foreign key constraint?
00:33 mizu_no_oto joined
00:33 <Welkin> TableNameId
00:33 <Welkin> just add Id to the end of it
00:34 <Welkin> for a Person, it would be PersonId
00:34 vikaton joined
00:34 <Welkin> yeah, template haskell is a pain in the ass
00:34 <Welkin> too much magic
00:34 drcode joined
00:34 <Welkin> you'll have to read up on docs for persistent/yesod or look at the source
00:34 <Welkin> but once you know how it works, it's great
00:34 nighty-- joined
00:35 <monarch_> Welkin: I get "no explicit primary key fdef=ForeignDef"
00:35 wujcin joined
00:35 Koterpillar joined
00:35 <Welkin> monarch_: http://www.yesodweb.com/book/persistent
00:35 <monarch_> Welkin: for "Foreign Entity entityId EntityId"
00:35 m1dnight_ joined
00:35 <Welkin> monarch_: what is the name of your entity?
00:36 <Welkin> It can't be Entity since that is already taken by Persistent
00:36 <Welkin> here is a simple example http://www.yesodweb.com/book/persistent#persistent_synopsis
00:36 JeanCarloMachado joined
00:37 Achylles joined
00:38 wroathe joined
00:38 <monarch_> Welkin: here's are really simple version of the problem https://pastebin.com/9FY6DnGS
00:38 <monarch_> that gets error "no explicit primary key fdef=ForeignDef"
00:39 beanbagula joined
00:39 <Welkin> monarch_: you don't need the Foreign part
00:39 <Welkin> look at the example I linked
00:39 scottj left
00:39 <Welkin> all you need is `dogId DogId`
00:39 <Welkin> this is written in a DSL using template haskell
00:39 <Welkin> it's "magic"
00:42 augur joined
00:42 arctictern joined
00:43 <monarch_> Welkin: I had read that tutorial and that was what I had tried before, the problem is that gives a INTEGER NOT NULL REFERENCES constraint
00:43 rameerez joined
00:43 <Welkin> yes
00:43 <Welkin> there are ways to specify a different primary key if you wish
00:44 <monarch_> Welkin: so there's no way to reference an implicit primary key as a foreign key
00:44 <Welkin> https://github.com/yesodweb/persistent/wiki/Persistent-entity-syntax
00:45 <Welkin> what is your implicit primary key?
00:45 <Welkin> you mean the default integer?
00:45 <monarch_> yes, the default INTEGER PRIMARY KEY
00:45 <monarch_> named "id"
00:45 Hunter1 joined
00:45 beerdrop joined
00:46 <Welkin> https://github.com/yesodweb/persistent/blob/master/persistent-test/src/CompositeTest.hs#L53
00:46 <arctictern> this is probably a stupid question, but does anyone know why this doesn't typecheck?
00:46 <arctictern> myTest :: (Bounded a) => a
00:46 <Welkin> there is an example of how you can do it
00:46 <arctictern> myTest = minBound :: a
00:46 <monarch_> Welkin: yup, that's what led me to try what was in that pastebin I sent
00:46 nomicflux joined
00:46 <Welkin> although from your error you pasted, it looks like your problem is that you are naming one of your tables "Entity", which is a type already taken by persistent
00:47 <monarch_> Welkin: no table is named Entity, I was just trying to be generic to not confuse you with my table names
00:47 <Welkin> youo have to be specific
00:47 <Welkin> and just paste you real error
00:47 <Welkin> your*
00:48 <Welkin> 20:35 < monarch_> Welkin: for "Foreign Entity entityId EntityId"
00:48 <Welkin> you also have an extra type at the end
00:48 <Welkin> there are no types in this case
00:49 <Welkin> try `Foreign Dog dog`
00:50 <Welkin> it also depends on what your primary key is for Dog
00:50 <Welkin> in this case, what is it?
00:50 <monarch_> Welkin: this is the error for "Foreign Dog dog": https://pastebin.com/jQL5C5PA
00:50 <Welkin> in the github example above, it is `Primary name name2 age`
00:50 mithrandeer joined
00:51 <Welkin> so the referncing table uses `Foreign TestParent fkparent name name2 age`
00:51 tromp joined
00:51 <monarch_> Welkin: yeah, they have an explicit primary key. But you can see from my first paste, that I do not, and I'm wondering if it's possible to not have an explicit key
00:51 <monarch_> and still use Foreign to link them
00:51 <Welkin> why do you need Foreign then?
00:51 <monarch_> that first paste being https://pastebin.com/9FY6DnGS
00:52 <Welkin> it should just work with `dogId Dog`
00:52 <monarch_> I need Foreign to have a Foreign Key Constraint
00:52 <Welkin> er
00:52 whaletechno joined
00:52 <Welkin> you should be able to
00:52 <monarch_> otherwise it's not a FOREIGN KEY, it's a NOT NULL REFERENCES constraint
00:52 <Welkin> try `Foreign Dog dog id`
00:52 takle joined
00:53 <monarch_> Welkin: same problem. https://pastebin.com/PtmntCaG
00:54 <Axman6> can I give a small word of warning? It's possbile to his the limits of persistent quite quickly if you need do do anything more difficult than what it was designed for, and esqueletto feels like a limited when comparexd to SQL and has comparatively weird syntax. I spent last weekend rewriting our persistent based app using hasql and I'm much happier for it
00:54 <Axman6> hit*
00:54 <Axman6> s/like a/quite/
00:54 <Welkin> persistent is meant to be a simple ORM
00:54 spion joined
00:55 <monarch_> Welkin: I should note that I'm using SQLite, which disables foreign keys by default, but I've supposedly turned them on using "set fkEnabled True $ mkSqliteConnectionInfo databaseName" elsewhere
00:55 umib0zu joined
00:55 <Welkin> when I had to do custom postgres things, I used the rawSql function
00:55 <Axman6> sadly it's not particularly simple
00:55 <monarch_> Axman: I've definitely done so before, it just needs to be done this way for this problem
00:55 <Squarism> Anyone can see why i get this error : http://lpaste.net/355091
00:55 justanotheruser joined
00:56 augur joined
00:56 <Welkin> monarch_: it looks like your error tells you what needs to be done
00:56 whaletechno joined
00:56 <Welkin> add an explicit primary key
00:56 <Squarism> im doing a liftIO in a WriterT typed function - i wonder why the foldM expects a WriterT when im in liftIO scope
00:56 <Welkin> then try it
00:56 <monarch_> Welkin: guess it's not possible. Okay. I'll adjust accordingly.
00:57 mithrandeer joined
00:57 <Koterpillar> Squarism: so I'm guessing ga_handleToGameMsg is IO something, and you need to lift it?
00:57 <monarch_> Welkin: thanks for looking through it with me
00:57 <Squarism> Koterpillar, it is
00:58 wroathe joined
00:58 <Squarism> Koterpillar, but the foldM is invoked in liftIO already - thats not enough?
00:59 skeet70 joined
01:00 <Squarism> Koterpillar, i thought "f" got type "IO ..."
01:00 <Koterpillar> Squarism: GHC tells you what type did f get
01:01 <Koterpillar> Squarism: perhaps you want to manually type it to MonadIO
01:01 <Squarism> yeah i guess ill try that
01:04 drcode joined
01:07 takle joined
01:07 Voldenet joined
01:07 Voldenet joined
01:07 jer1 joined
01:08 mithrandeer joined
01:08 thunderrd_ joined
01:09 wroathe joined
01:09 systadmin joined
01:10 ystael joined
01:10 rameerez joined
01:13 Cale joined
01:16 drcode joined
01:16 butterthebuddha joined
01:17 idyll joined
01:17 blym_ joined
01:19 louispan joined
01:20 rameerez joined
01:21 darjeeling_ joined
01:22 erikd joined
01:22 takle joined
01:25 CG_ joined
01:25 takle_ joined
01:26 meba joined
01:26 drostie joined
01:26 systemfault joined
01:26 gugah joined
01:27 flatmap13 joined
01:29 wroathe joined
01:29 Supersonic112_ joined
01:29 Vorpal joined
01:29 Vorpal joined
01:29 raynold joined
01:31 <drostie> Was wondering if anyone else remembered this: I have a dim memory of someone who was essentially describing a heterogeneous list of arrows which all agreed on their intermediate representations, something which would store something like `data ArrList arr x y = A1 (arr x y) | A2 (arr x k, arr k z) | A3 (arr x k, arr k l, arr l y) | A4 (arr x k, arr k l, arr l m, arr m y) | ...`. Am I misremembering something or crazy or is there some type-level trickery to
01:31 <drostie> make that sort of list-type thing happen?
01:32 plot joined
01:33 <byorgey> drostie: not crazy at all. http://hackage.haskell.org/package/thrist
01:33 <drostie> whoops, that second one should be A2 (arr x k, arr k y)
01:33 <byorgey> I have seen this idea show up in multiple places so there might be something else you are remembering as well
01:34 <byorgey> free Applicatives are somewhat related as well https://hackage.haskell.org/package/free-4.12.4/docs/Control-Applicative-Free.html
01:35 butterthebuddha joined
01:35 <drostie> Thanks, I'll look at those. :D
01:36 firef1y joined
01:37 mdjnewman joined
01:39 wroathe joined
01:40 blym_ joined
01:41 filterfish joined
01:42 <lpaste> lambdafan pasted “Need Help With My Evaluator” at http://lpaste.net/136471726836940800
01:42 <lpaste> lambdafan pasted “Need Help With My Evaluator” at http://lpaste.net/2788601744215506944
01:43 takle joined
01:45 mizu_no_oto joined
01:46 mithrandeer joined
01:49 wroathe joined
01:49 <lambdafan> ah yeah scratch that
01:50 plot joined
01:53 blym_ joined
01:54 aarvar joined
01:55 robatosan joined
01:55 freeside joined
01:56 ehsanullahjan joined
01:58 ertes joined
01:59 louispan joined
02:00 hucksy joined
02:02 sgronblo joined
02:02 takle joined
02:02 eschnett joined
02:03 blym_ joined
02:04 vaibhavsagar joined
02:07 splanch joined
02:08 simukis_ joined
02:11 <iqubic> So, how does StateT work?
02:11 Aruro joined
02:11 <iqubic> Like can I get an example of StateT IO a being used?
02:12 <glguy> What've you tried so far?
02:12 <glguy> Which part don't you understand?
02:13 <iqubic> I haven't tried anything. And I understand nothing.
02:13 takle joined
02:13 <glguy> OK, in that case you should start here to at least see the operations and the types available http://hackage.haskell.org/package/transformers-
02:13 wroathe joined
02:14 <glguy> There are even examples there
02:14 <iqubic> Looks like you can construct a StateT with the state function.
02:15 <iqubic> How does that decide what Monad to use?
02:15 lambdafan joined
02:15 <glguy> It doesn't decide, you do
02:16 <iqubic> But when?
02:16 ddere joined
02:16 <iqubic> When do you select the monad that the return type will use?
02:17 Chobbes joined
02:17 chirpsalot joined
02:17 ljhms joined
02:19 <glguy> When you write your program. Maybe make an example where this is confusing and put it on lpaste.net
02:19 takle joined
02:20 <iqubic> Actually I found a talk about monad transformers. Watching it now.
02:21 cyberlard joined
02:22 blym_ joined
02:22 soniku joined
02:23 <iqubic> Do people find it helpful to write their own typeclasses?
02:23 <iqubic> Or is that commonly done?
02:23 <iqubic> *Not
02:23 <glguy> 3 minute talk on monad transformers?
02:24 <lpaste> lambdafan pasted “Need Help With My Evaluator - redux” at http://lpaste.net/5956570558047977472
02:24 <iqubic> glguy, it's 56 minutes long. I'm just asking questions in the middle of the talk.
02:26 ajp joined
02:26 <glguy> lambdafan: You don't know that num equal Integer
02:28 <glguy> (and you only have an instance for Integer)
02:28 <glguy> Equals :: Expr (Number num) -> Expr (Number num) -> Expr Bool
02:28 <glguy> This constructor will work for other choices of num, too
02:28 <lambdafan> yes I would like it too
02:29 ljhms joined
02:29 <lambdafan> I just want one constructor for both Ints and Doubles
02:30 <glguy> lambdafan: Perhaps you want another GADT for Number, instead of a data family
02:30 <lambdafan> glguy, hmm I had tried that prior
02:30 <lambdafan> okay I will try that direction again
02:30 <lambdafan> glguy: I would then need an eval function for that gadt as well yes?
02:31 <glguy> lambdafan: That'd be a good idea
02:31 Hunter1 joined
02:32 e14 joined
02:33 <iqubic> What's a data family?
02:34 wroathe joined
02:34 <glguy> this is a good place to start https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#ghc-flag--XTypeFamilies
02:35 takle joined
02:36 <glguy> also https://wiki.haskell.org/GHC/Indexed_types
02:37 wujcin joined
02:37 <glguy> the wiki link is probably a better starting point
02:37 <lambdafan> I found stack overflow helpful
02:39 sleffy joined
02:42 exferenceBot joined
02:43 takle joined
02:43 butterthebuddha joined
02:44 shangxiao joined
02:44 wroathe joined
02:46 gugah joined
02:46 Hunter1 joined
02:46 hexagoxel joined
02:49 drostie joined
02:50 howdoi joined
02:51 splanch joined
02:51 blym_ joined
02:51 takle joined
02:51 <glguy> lambdafan: Did you get it working?
02:51 darjeeling_ joined
02:53 spatial joined
02:53 <spatial> find :: Container c e => (e -> Bool) -> c e -> [IndexOf c] in https://hackage.haskell.org/package/hmatrix-
02:53 <spatial> Doesn't accept Vector.
02:54 wroathe joined
02:55 ogkloo joined
02:55 butterthebuddha joined
02:56 xcmw joined
02:56 modal joined
02:56 <glguy> spatial: It'd help to see the actual error message and the code
02:58 takle joined
02:59 <spatial> http://lpaste.net/355093
03:00 sgronblo joined
03:01 <pacak> IO (Vector Double) as input parameter seems wrong.
03:01 <glguy> pacak: Make sure you're using Vector as exported from Numeric.LinearAlgebra
03:01 <glguy> err
03:01 <glguy> spatial: Make sure you're using Vector as exported from Numeric.LinearAlgebra
03:01 <pacak> spatial: s/mat/m/ ?
03:02 <pacak> spatial: At line 4
03:02 <glguy> Yeah, that's certainly going to need to be fixed, too :)
03:03 <spatial> Sorry. Mislead by the error. Fixed it.
03:04 <spatial> I mean fixed Line 4
03:04 arctictern joined
03:05 arctictern joined
03:06 arctictern joined
03:06 <glguy> spatial: If there's a new error you can annotate that onto the paste with the fixed code
03:06 <glguy> We can't load your code, its missing imports
03:06 Xanather joined
03:07 arctictern joined
03:07 <spatial> glguy: No new error. Code is long.
03:08 arctictern joined
03:08 mjora7 joined
03:11 tomboy64 joined
03:11 otto_s joined
03:12 Argue__ joined
03:15 wroathe joined
03:15 felixsch__ joined
03:16 blym_ joined
03:16 takle joined
03:17 arquebus joined
03:19 binaryplease joined
03:20 latro`a joined
03:20 <qmm> > if (any (== Nothing) [Just 1, Just 2, Just 3]) then (any (== Nothing) [Just 1, Just 2, Just 3] else False
03:20 <lambdabot> <hint>:1:96: error: parse error on input ‘else’
03:21 butterthebuddha joined
03:22 <qmm> i am trying to say, if the first list of values contains a Nothing, then check that a second group of values has a Nothing value. if both of the lists contains a Nothing then return False and otherwise if the first list doesn't contain Nothing, return it. otherwise if the second list doesn't contain a Nothing, return it
03:23 CraftyFellow joined
03:23 <iqubic> What is this: https://hackage.haskell.org/package/extensible-effects
03:23 <qmm> it feels weird asking how to do this, maybe i need to think about it longer than 30 seconds
03:24 <iqubic> That thing bills itself as the eff monad.
03:24 <glguy> > find (all isJust) [ [Just 1, Nothing] , [Just 1, Just 2, Just 3] ]
03:24 <lambdabot> Just [Just 1,Just 2,Just 3]
03:24 lambdaman joined
03:24 biglambda joined
03:24 <iqubic> :t find
03:24 <lambdabot> Foldable t => (a -> Bool) -> t a -> Maybe a
03:24 <iqubic> :t isJust
03:25 <lambdabot> Maybe a -> Bool
03:25 <glguy> or: a> asum (map sequence [ [Just 1, Nothing] , [Just 1, Just 2, Just 3] ] )
03:25 <glguy> > asum (map sequence [ [Just 1, Nothing] , [Just 1, Just 2, Just 3] ] )
03:25 <lambdabot> Just [1,2,3]
03:25 <glguy> instead of returning a list with all Just constructed values
03:25 <glguy> it returns Just of the list
03:25 <qmm> that is really nice!
03:26 <glguy> :t foldMap sequenceA
03:26 <lambdabot> (Foldable t, Applicative f, Traversable t1, Monoid (f (t1 a))) => t (t1 (f a)) -> f (t1 a)
03:26 <glguy> Hmm, that's a more complicated type than I had in mind, but it does the same thing in this case
03:27 xcmw joined
03:27 meba joined
03:27 <glguy> > foldMap sequenceA [ [Nothing, Just 1], [Just 2, Just 3], [Just 4] ]
03:27 <lambdabot> Just [2,3,4]
03:27 <glguy> oh, no it doesn't :)
03:27 <glguy> that one collects all the lists together that had no Nothings in them
03:28 <pacak> I think you can use MonadPlus or Alternative here
03:28 <glguy> pacak: Yeah, that's what asum did
03:28 <pacak> foldMap will try to fold all the things
03:28 <glguy> right
03:28 <pacak> (didn't noticed asum)
03:29 CraftyFellow left
03:29 jabpe joined
03:30 sanitypassing joined
03:31 omilu joined
03:32 takle joined
03:32 <kamyar> Hello fellows
03:32 louispan joined
03:32 <kamyar> PLease help me with the code snippet
03:33 <kamyar> http://lpaste.net/355094
03:34 <kamyar> The last line of function post gives the below error
03:34 <kamyar> token is of type IO String, but json function (in scotty) needs String
03:34 <kamyar> How can I fix it?
03:34 <Axman6> so what's the type of json?
03:35 <kamyar> json :: ToJSON a => a -> ActionM ()
03:35 tromp joined
03:35 <Axman6> ah, try json =<< instead
03:35 <kamyar> Sorry! json gets any object not string
03:35 wroathe joined
03:35 <kamyar> and token is of Type newtype TokenInfo = TokenInfo {token :: String} deriving (Show, Generic)
03:35 spatial joined
03:36 <pacak> Looks ugly.
03:36 <pacak> Factor out token?
03:36 <kamyar> Axman6: Does not work
03:37 <kamyar> pacak: What do u mean?
03:37 <pacak> With full type signature
03:37 <Axman6> "does not work" is not a type error I can help you with ;)
03:37 <pacak> As far as I can see Token refers to nothing inside your monadic action
03:37 <Axman6> look at the line before
03:38 splanch_ joined
03:38 <kamyar> Thanks Axman6! json =<< lift token Worked!
03:39 <pacak> Axman6: Lines 4..6 refer to each other, but they are not related to anything inside the monadic action
03:39 <kamyar> pacak: What do u mean? token is filled and working
03:39 takle joined
03:40 <kamyar> WoW! It Worked!
03:40 <kamyar> Axman6: What does =<< do? it is second time it saved me!
03:40 <pacak> :t (=<<)
03:40 <lambdabot> Monad m => (a -> m b) -> m a -> m b
03:40 <pacak> :t (>>=)
03:40 <lambdabot> Monad m => m a -> (a -> m b) -> m b
03:40 <pacak> @src (=<<)
03:40 <lambdabot> f =<< x = x >>= f
03:41 splanch__ joined
03:41 <Axman6> :t (<*>)
03:41 <lambdabot> Applicative f => f (a -> b) -> f a -> f b
03:41 <Axman6> :t (=<<)
03:41 <lambdabot> Monad m => (a -> m b) -> m a -> m b
03:41 <Axman6> notiveuh
03:41 <Axman6> :t (<$>)
03:41 <lambdabot> Functor f => (a -> b) -> f a -> f b
03:42 aki_ joined
03:42 splanch joined
03:42 <Axman6> notice that =<< takes a "monadic function"
03:42 <kamyar> I know about <$> and <*> , but did not remind =<<
03:42 <kamyar> Thanks anyway!
03:42 sellout- joined
03:45 <kamyar> Axman6: Yes! json in fact gets a type and returns a monadic value to feed Scotty! So your notation worked! Since my token variable is monad itself and I needed its containing value
03:45 wroathe joined
03:46 falafel joined
03:49 takle joined
03:52 mithrandeer joined
03:53 butterthebuddha joined
03:54 <iqubic> @src return
03:54 <lambdabot> Source not found.
03:54 <iqubic> Why not?
03:54 <iqubic> Is it because Monad is a typeclass?
03:54 <iqubic> @src >>
03:54 <lambdabot> m >> k = m >>= \_ -> k
03:54 <Koterpillar> iqubic: yes, because return is different for every monad
03:55 lambdafan joined
03:55 <Koterpillar> iqubic: and also, the src command isn't GHC-accurate
03:55 robatosan joined
03:56 <iqubic> But >> looks right.
03:56 <Koterpillar> because it can be expressed using >>=
03:56 wroathe joined
03:56 <iqubic> Ah.
03:56 <iqubic> Can't @src just say "return = pure"?
03:56 <Koterpillar> @src join
03:56 <lambdabot> join x = x >>= id
03:56 sgronblo joined
03:57 <iqubic> That's not right at all.
03:57 <iqubic> Least, I don't think so.
03:57 <Koterpillar> which one, join?
03:57 <iqubic> Join doesn't look right
03:57 <iqubic> > Just (Just 5) >>= id
03:57 <lambdabot> Just 5
03:57 <Koterpillar> return = pure yes, I suppose it can, but @src isn't a replacement for searching Hackage yourself
03:58 <Koterpillar> http://hackage.haskell.org/package/base-
03:58 <iqubic> > Just (Nothing) >>= id
03:58 <Axman6> join is definitely right
03:58 <lambdabot> Nothing
03:58 splanch joined
03:58 <iqubic> > Nothing >>= id
03:58 <lambdabot> Nothing
03:58 <Koterpillar> > Nothing >>= undefined
03:58 <lambdabot> Nothing
03:58 <iqubic> How does that join work?
03:58 <Axman6> try it out by hand for a few different monads
03:59 <Koterpillar> iqubic: find out the type of x >>= id
03:59 splanch_ joined
03:59 <Axman6> like Maybe, [], Either
03:59 <iqubic> IO (IO Int) >>= Join
03:59 <iqubic> > IO (IO Int) >>= Join
03:59 <lambdabot> error:
03:59 <lambdabot> • Data constructor not in scope: IO :: t0 -> m a0
03:59 <lambdabot> • Perhaps you meant one of these:
04:00 <iqubic> Looks like that doesn't work
04:00 <glguy> Yeah, IO isn't a data constructor
04:00 <Koterpillar> :t (undefined :: IO (IO Int)) >>= join
04:00 <lambdabot> error:
04:00 <lambdabot> • Couldn't match type ‘Int’ with ‘IO b’
04:00 <lambdabot> Expected type: IO Int -> IO b
04:00 <Koterpillar> :t (undefined :: IO (IO Int)) >>= id
04:00 <lambdabot> IO Int
04:00 <glguy> iqubic: Go back to trying Maybe. [], and Either Something, as suggested
04:00 <iqubic> > [[1, 2, 3] [4, 5, 6] [7, 8, 9] [10]]
04:00 <lambdabot> error:
04:00 <lambdabot> • Couldn't match expected type ‘[Integer]
04:00 <lambdabot> -> [Integer] -> [Integer] -> t’
04:01 <iqubic> > [[1, 2, 3] [4, 5, 6] [7, 8, 9] [10]] >>= id
04:01 orhan89 joined
04:01 <lambdabot> error:
04:01 <lambdabot> • Couldn't match expected type ‘[Integer]
04:01 <lambdabot> -> [Integer] -> [Integer] -> [b]’
04:01 <iqubic> What's wrong with that?
04:01 <Koterpillar> iqubic: commas between lists
04:01 <iqubic> > [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] >>= id
04:01 <lambdabot> [1,2,3,4,5,6,7,8,9,10]
04:02 <iqubic> > Right (Right "Hello") >>= id
04:02 <lambdabot> Right "Hello"
04:02 <iqubic> > Right (Left "Hello") >>= id
04:02 <lambdabot> Left "Hello"
04:02 <iqubic> > Left (Left "Hello") >>= id
04:02 <lambdabot> Left (Left "Hello")
04:02 <iqubic> > Left (Right "Hello") >>= id
04:02 <lambdabot> Left (Right "Hello")
04:02 <iqubic> What?
04:02 <Koterpillar> tee hee
04:03 <iqubic> What the heck???
04:03 <Koterpillar> Either monad never changes the error type
04:03 <iqubic> You can't join if the outer part is Left?
04:03 <Koterpillar> if it started as Either String, it'll be Either String
04:03 <iqubic> So I see how join works.
04:03 RayNbow` joined
04:03 <Koterpillar> you started as Either (Either String a), and you'll end up with Either (Either String a)
04:03 <Koterpillar> iqubic: try fmap on Either
04:04 <Koterpillar> > fmap negate (Right 1)
04:04 <lambdabot> Right (-1)
04:04 <Koterpillar> > fmap negate (Left 1)
04:04 <lambdabot> Left 1
04:04 <iqubic> Wait, that never changes the type or value of the error.
04:04 <Koterpillar> correct
04:04 flatmap13 joined
04:04 <Koterpillar> you want the function under fmap to work on the actual values, not the error
04:05 <Koterpillar> > fmap negate (Left "haahaahahahaa")
04:05 <lambdabot> Left "haahaahahahaa"
04:05 <Koterpillar> (what did you expect here?)
04:05 jer1 joined
04:05 <Koterpillar> > fmap negate (Left (Left (Left "haahaahahahaa")))
04:05 <lambdabot> Left (Left (Left "haahaahahahaa"))
04:06 <iqubic> > fmap negate Left $ Left $ Right -5
04:06 <lambdabot> error:
04:06 <lambdabot> • No instance for (Typeable b0)
04:06 <lambdabot> arising from a use of ‘show_M662705632048384262710688’
04:06 <iqubic> > fmap negate Left (Left (Right -5))
04:06 <lambdabot> error:
04:06 <lambdabot> • No instance for (Typeable b0)
04:06 <lambdabot> arising from a use of ‘show_M572224612319037068310699’
04:06 <Koterpillar> more brackets
04:06 <iqubic> > fmap negate $ Left $ Left $ Right -5
04:06 <lambdabot> error:
04:06 <lambdabot> • No instance for (Typeable b0)
04:06 <lambdabot> arising from a use of ‘show_M693465644332150467910714’
04:06 <iqubic> > fmap negate (Left (Left (Right -5)))
04:06 <lambdabot> error:
04:06 <lambdabot> • No instance for (Typeable b0)
04:06 <lambdabot> arising from a use of ‘show_M823180959412907230410747’
04:07 <Koterpillar> > (-5)
04:07 <lambdabot> -5
04:07 <iqubic> > fmap negate (Left (Left (Right (-5))))
04:07 <lambdabot> Left (Left (Right (-5)))
04:08 <Koterpillar> iqubic: if you try writing the Monad instance for Either yourself, you'll see that this is the only thing that can ever happen
04:08 <Koterpillar> (well, Functor for a start)
04:08 <iqubic> I'll do that.
04:08 <iqubic> Just not now.
04:08 takle joined
04:08 <iqubic> I have homework to do.
04:08 <iqubic> But I'd love to do that.
04:09 <iqubic> Then maybe try ExceptT too.
04:09 <iqubic> Like try writing that out myself too.
04:10 <iqubic> And, as before, type holes are my friend
04:10 wroathe joined
04:12 <iqubic> Just write a skeleton, use a type hole. Fill in part of the type hole, get a new type hole. Repeat.
04:12 blym_ joined
04:14 fakenerd joined
04:17 juhp_ joined
04:17 juhp_ joined
04:17 takle joined
04:18 forgottenone joined
04:20 wroathe joined
04:22 mbuf joined
04:22 KitC joined
04:22 takle joined
04:26 zv joined
04:27 oish joined
04:28 cyborg-one joined
04:29 saurabhnanda joined
04:29 wei2912 joined
04:30 <saurabhnanda> is there a way to build a collection/list of types? something like `AllCustomFields = [SingleLineField, MultiLineField, CheckboxField]`
04:31 <Koterpillar> and do what with it?
04:32 saurabhn_ joined
04:32 <saurabhn_> is there a way to build a collection/list of types? something like `AllCustomFields = [SingleLineField, MultiLineField, CheckboxField]`
04:33 <Koterpillar> and do what with it?
04:34 <* ski> is seeing double
04:34 <* pacak> confirms
04:34 louispan joined
04:34 <* iqubic> also confirms
04:35 wroathe joined
04:36 takle joined
04:38 <saurabhn_> Koterpillar: loop over it in the UI?
04:38 <saurabhn_> Koterpillar: "What kind of field do you want? <Single Line, Multi Line, Checkbox, ...>
04:39 <Koterpillar> data FieldType = SingleLineField | MultiLineField | CheckboxField
04:40 <saurabhn_> Koterpillar: nope, they need to be **TYPES** for various other reasons.
04:40 <pacak> class UI_Loopable
04:40 <iqubic> Why do they need to be types?
04:41 <saurabhn_> data SingleLineField = SingleLineField {slfName :: Text, slfHelpText :: Text, slfMinLength :: Int, slfMaxLength :: Int}
04:41 <saurabhn_> data MultiLineField = MultiLineField {mlfName :: Text, mlfHelpText :: Text, mlfMinLength :: Int, mlfMaxLength :: Int, mlfRows :: Int}
04:41 <pacak> data Loopable = forall a. UI_Loopable UL a
04:41 <pacak> [UL <single line>, UL ... ]
04:41 <Koterpillar> ^ that is one way
04:42 <saurabhn_> pacak: come again?
04:42 <iqubic> pacak: can't he just use an ADT with different records for each constructor?
04:42 <pacak> (12:40:32) pacak: class UI_Loopable
04:42 <pacak> (12:41:11) pacak: data Loopable = forall a. UI_Loopable UL a
04:42 <pacak> (12:41:28) pacak: [UL <single line>, UL ... ]
04:42 <iqubic> pacak: Would the class UI_Loopable have any functions with it?
04:43 <Koterpillar> I still feel like at some point, you'll need a function from FieldType to Loopable
04:43 mizu_no_oto joined
04:43 systadmin joined
04:43 <iqubic> Yeah.
04:43 <glguy> Another option is to make a new list type, normal [] is by definition a list of values that all have the same type.
04:43 <pacak> iqubic: If the goal is only to loop in UI - probably not, but if he wants to perform any operations - probably yes.
04:43 <iqubic> But what about my suggestion?
04:43 <glguy> but the sum type solution is the most likely best
04:43 <iqubic> can't he just use an ADT with different records for each constructor?
04:44 <iqubic> Won't that work?
04:44 <Koterpillar> GADT, yes
04:44 <saurabhn_> iqubic: that was my firt attempt
04:44 <iqubic> What's a GADT?
04:44 nshepperd joined
04:44 <saurabhn_> iqubic: but it doesn't work when you need to define typeclass instances for each ADT value.
04:44 <iqubic> generalized ADT?
04:44 <saurabhn_> because typeclass instances can be defined only for *types*, not *ADT values*
04:44 <Koterpillar> data Field where SingleLine :: Text -> Text -> Int -> Int -> Field; MultiLine :: Text -> Text -> Int -> Int -> Int -> Field
04:44 <glguy> That's not a GADT, it just happens to use the syntax...
04:45 <pacak> that's just sum type
04:45 <iqubic> what is GADT?
04:45 <glguy> Where are GADTs coming into the solution?
04:45 <Koterpillar> actually, yes
04:45 codesoup joined
04:45 <Axman6> 6psurely you meant data Loopable \ forall a. UI_Loopable a => UL a?
04:45 wroathe joined
04:45 <Axman6> s/\/=
04:45 <Axman6> bloody hell, struggining with this new keyboard
04:45 <Axman6> sdfgkjh
04:45 brynedwardz joined
04:46 <saurabhn_> glguy: this has actually nothing to do with GADTs. My original question was very straightforward, how do define a list of types.
04:46 <Axman6> saurabhn_: the problem is that this isn't straightforward
04:47 <iqubic> saurabhn_: Doesn't look like you can. At least not easily
04:47 <glguy> saurabhn_: the problem is that a list of types probably isn't what you actually want
04:47 <pacak> ['Int, 'Word] -- list of types!
04:47 <glguy> it sounds like you might be asking for a list of values that don't all have the same type (which is something else)
04:47 <Koterpillar> so you've got the value (of some type) back from the UI, what do you do with it?
04:47 <saurabhn_> glguy: well at this point in my design, that's exactly what I want :)
04:47 <glguy> saurabhn_: you can have a list of types, turn on DataKinds and make one
04:48 <Koterpillar> saurabhn_: you are describing a solution that you want; what is your problem?
04:48 takle joined
04:48 <glguy> '[Int, Bool, Char] :: [*]
04:48 <glguy> but surely that's not going to help you
04:48 <glguy> that's a "list of types"
04:48 <iqubic> What is DataKinds?
04:48 <saurabhn_> writing an RFC on Reddit
04:48 <saurabhn_> kinda hard to exlain
04:48 <Koterpillar> saurabhn_: ultimately, you'll have to use this list to create a value, right?
04:48 <iqubic> I think what he wants here is a parser.
04:49 <glguy> saurabhn_: Was that list of types what you were looking for?
04:49 <saurabhn_> hang on, hang on.
04:49 samp joined
04:49 <saurabhn_> [SingleLineField, MultiLineField, CheckboxField, DropdownField]
04:50 <* pacak> sighs
04:50 <glguy> OK, you're done. that's a list of types
04:50 SrPx joined
04:50 <SrPx> Where can I read about Philip Wadler's history and contributions to Haskell?
04:51 robatosan joined
04:51 <pacak> Are you trying to do Java in Haskell?
04:51 shangxiao joined
04:52 <saurabhn_> https://www.reddit.com/r/haskell/comments/68k456/rfc_how_to_model_types_with_some_common_behaviour/
04:53 mmachenry joined
04:53 <Koterpillar> are you sure this isn't GADT?
04:53 BartAdv joined
04:54 <saurabhn_> pacak: oh please. I'm sick of people trying to bash down idioms from other languages without trying to come up with viable idioms of their own. Please don't tell me how NOT to do things in Haskell. Please tell me the right way to do things in Haskell. That's far more constructive. /end of rant.
04:54 <Koterpillar> data Field where Checkbox :: Field Bool; SingleLine :: Field Text; MultiLine :: Field [Text]
04:54 <Koterpillar> saurabhn_: ^
04:54 <ski> .. it would help if we knew what you wanted to do
04:55 wroathe joined
04:55 <glguy> Koterpillar: That won't load
04:55 <saurabhn_> ski: I know. Tried putting a long-form explanation on Reddit at https://www.reddit.com/r/haskell/comments/68k456/rfc_how_to_model_types_with_some_common_behaviour/
04:55 <Koterpillar> glguy: yeah, I missed a type parameter
04:55 <glguy> Koterpillar: and when you add the parameter it won't help
04:56 <glguy> now you can't write: [Checkbox, SingleLine]
04:56 <saurabhn_> ski: glguy: does the context in the Reddit post help?
04:57 <Koterpillar> glguy: you're right
04:58 <glguy> saurabhn_: You can just have: data Field = Checkbox | Singleline | Multiline...
04:58 <Koterpillar> glguy: combined with a forall type though?
04:59 <glguy> and then some logic that generates the next form based on the choice
04:59 <glguy> lists of types don't factor in here
04:59 <saurabhn_> glguy: is there a way to define typeclass instances for ADT values?
04:59 <ski> i don't understand what `FilterEq' is for, and so i don't understand "the good think about giving each field-type its own separate Haskell type is that one can define typeclass instances easily"
04:59 <glguy> You can only define type class instances for types
05:00 <ski> (i also don't know what the alternative(s ?) to "giving each field-type its own separate Haskell type" would be, in your mind)
05:01 <Lokathor> the drop function on Text is O(n), which seems unfortunate
05:01 <Lokathor> but i'm no UTF-16 expert
05:01 <glguy> Lokathor: that's the magic of variable width encodings like utf-16 and utf-8
05:01 teggi joined
05:02 <Lokathor> but Text says that, internally, it's always UTF-16
05:02 sleffy joined
05:02 <glguy> and utf-16 is variable width
05:02 <Lokathor> but can't it just advance a pointer however many bytes the first character is, and then the rest of the bytes stay the same width?
05:03 leat joined
05:03 <Lokathor> because Text.head is O(1), which is what's strange to me you see
05:03 <glguy> each code point takes either 16-bit or 32-bit
05:03 <Axman6> each utf-16 codepoint is 16 bits, but they may be combined
05:03 <Axman6> iirc
05:03 <Lokathor> ah, oh well
05:04 <Axman6> (my knowledhe of the exact terminology is pretty poor)
05:04 <Axman6> so finding the nth codepoint is O(1) but the nth... character? is O(n)
05:04 <glguy> U+10000 to U+10FFFF are encoded as "surrogate pairs"
05:04 wroathe joined
05:05 <glguy> so indexing a Text has to be O(n), too
05:05 <Axman6> yeah
05:06 <Lokathor> wait wait
05:06 fakenerd joined
05:06 <Lokathor> is the 'n' in drop's O(n) the Text length or the drop value?
05:06 <cocreature> drop value
05:07 <Lokathor> ohhhhhh, okay that makes sense :P
05:07 <Axman6> I think it must be the length
05:07 <iqubic> So going back to what saurbahn_ wanted, can't he just use pattern matching to get filterEq to work with an ADT?
05:07 <cocreature> Axman6: huh? why
05:07 <Axman6> in the worst case you might have to look at the whole Text value
05:07 <Axman6> because of the above problem
05:07 <cocreature> Axman6: right but then the drop value is larger than the Text length so O(drop value) still works
05:08 <Lokathor> Axman6, if you can look at the head in O(1), i'm not sure why you can't drop 1 in O(1), for example
05:08 <nshepperd> you have to decode each character that you drop to identify its size
05:09 <nshepperd> you don't need to look at the rest of the string
05:09 takle joined
05:09 Hunter1 joined
05:10 <Axman6> https://en.wikipedia.org/wiki/UTF-16#Description
05:10 <nshepperd> 'drop n xs' is even O(min(n, length xs)), really
05:10 fakenerd_ joined
05:11 <Axman6> afaict, the maximum size of a single unicode codepoint is two 16 bit values
05:13 <iqubic> Whis the difference between UTF-16 and UTF-8?
05:13 lambdaman joined
05:14 <iqubic> s/Whis/What is
05:14 <Lokathor> http://lpaste.net/355095 whee
05:14 <nshepperd> Axman6: yes. so drop n takes n steps
05:15 <nshepperd> each step being O(1) to uncons 2 bytes, check whether it's a surrogate pair, and if so uncons another 2 bytes
05:16 crobbins joined
05:16 <Maxdamantus> is the goal to split by codepoints or characters?
05:17 <Maxdamantus> note that something like 'a】is represented as two codepoints.
05:18 <Maxdamantus> assuming my phone's terminal didn't mess that up.
05:18 <Maxdamantus> > "a\769"
05:18 <lambdabot> "a\769"
05:19 <ski> > text "a\769"
05:19 <lambdabot>
05:19 <ski> > "á"
05:20 <lambdabot> "\225"
05:20 <pacak> > "аa"
05:20 <lambdabot> "\1072a"
05:20 <nshepperd> codepoints, probably. can't represent a sequence of combining diacritics with a Char
05:20 arctictern joined
05:23 lambdaman joined
05:23 <ski> > "á"
05:23 <lambdabot> "a\769"
05:23 takle joined
05:24 <iqubic> >"a?"
05:24 <iqubic> > "a?"
05:24 <lambdabot> "a?"
05:24 keutoi joined
05:25 <iqubic> Can GeneralizedNewtypeDeriving became an official part of Haskell please?
05:25 <iqubic> Thank you.
05:26 saurabhnanda joined
05:26 nshepper1 joined
05:27 cantstanya joined
05:27 Hunter1 joined
05:29 eminhi joined
05:29 _sg joined
05:31 takle joined
05:31 suppi joined
05:33 biglambda joined
05:33 osa1 joined
05:33 osa1 joined
05:34 splanch joined
05:37 blym_ joined
05:40 soniku joined
05:45 mmachenry1 joined
05:46 blym_ joined
05:46 eminhi joined
05:47 JuanMiguel joined
05:50 tromp joined
05:51 takle joined
05:52 ninjazoete joined
05:56 blym_ joined
05:57 wizwizwizwiz joined
05:57 micmus joined
05:57 jer1 joined
05:57 <wizwizwizwiz> is there any hope of one programming language coming to dominate most application domains
05:57 hurkan joined
05:57 <wizwizwizwiz> or is a diversity of languages an inevitability
05:58 <pacak> wizwizwizwiz: There's no hope.
05:58 <wizwizwizwiz> pacak: is there a no hope theorem?
05:58 <wizwizwizwiz> perhaps we need a new hope,...
05:59 <wizwizwizwiz> care to justify that perspective?
06:00 splanch joined
06:01 <pacak> Let's pick language A - arbitrary assembly language for a low powered SoC. Let's pick language B - a theorem prover that can prove that a + a = b + a and can probably even calculate how much 4 + 5 is (taking a few minutes on that).
06:01 <pacak> Then try to apply language A where language B fits and vice versa.
06:01 <wizwizwizwiz> well,... one might argue that theorem provers should be separated as "language tooling"
06:01 <wizwizwizwiz> so you specify the program in the programming language
06:01 louispan joined
06:02 <wizwizwizwiz> but then can reason about certain properties of it which are not part of the language using the tooling
06:02 isBEKaml joined
06:03 spatial joined
06:03 <spatial> hmatrix Vectors are mutable ?
06:03 castlelore joined
06:03 castlelore joined
06:04 <cocreature> spatial: afaik they are
06:04 <cocreature> eh no I meant immutable
06:04 <spatial> How can I change and element ? Some references to runST are there
06:04 <pacak> spatial: I don't think soi.
06:05 <spatial> http://dis.um.es/~alberto/material/hmatrix.pdf
06:05 <Axman6> There might be mutable versions of each type, like how Vector does things
06:05 splanch_ joined
06:06 splanch joined
06:06 <spatial> Page 16.
06:06 <cocreature> there is https://hackage.haskell.org/package/hmatrix-
06:06 takle joined
06:06 <glguy> There are unsafe operations that can turn an "immutable" storable vector into a mutable one, (and safe versions, too, that copy)
06:07 <pacak> cocreature: But that's STVector, not Vector :)
06:07 <glguy> the operations are called "thaw" and "freeze"
06:07 <cocreature> right
06:07 <glguy> But one will find unexpected results trying to mutable otherwise "immutable" vectors and then using them again
06:08 <pacak> (unsafe thaw and freeze can lead to enormous amounts of fun https://github.com/tibbe/unordered-containers/issues/147)
06:09 <spatial> I started with a Vector
06:09 <pacak> I especially like the part when `a /= b && show a == show b` holds for a, b :: Int.
06:10 <pacak> Or even show a /= show b && show a == show b...
06:10 <cocreature> pacak: I’ve seen this bug report and the corresponding ghc issue before but I’m still scared by it
06:10 iomonad joined
06:10 <wizwizwizwiz> i find it intersting that the mathematics/physical sciences/engineering community has a very uniform notation for mathematics with only minor variations (like i versus j for current or transposed matrix representations in computer graphics)
06:12 <wizwizwizwiz> that is a pretty remarkable accomplishment
06:12 takle joined
06:17 <spatial> You mean I can copy the Vector and change it ?
06:17 <pacak> thaw, change, freeze
06:18 event_null joined
06:21 edsko joined
06:22 blym_ joined
06:29 <Myrl-saki> How to add documentation for a package I want to publish to Hackage?
06:30 forker joined
06:31 <cocreature> Myrl-saki: are you asking how to upload the generated haddocks it or how you can add haddock documentation to your package?
06:31 zeroed joined
06:31 bvad joined
06:31 <Myrl-saki> The latter, I think.
06:31 <cocreature> the haddock user guide is fairly readable https://www.haskell.org/haddock/doc/html/
06:32 <cocreature> you can generate the haddocks using `cabal haddock` or `stack haddock`
06:32 vlatkoB joined
06:32 <Myrl-saki> Thanks. I'll give it a try.
06:32 shangxiao joined
06:33 <cocreature> also just looking at the source of packages on hackage can help figuring out the markup for specific kinds of documentation
06:33 <Myrl-saki> I get MemoTrie errors, I think?
06:33 eminhi joined
06:34 <cocreature> you’re going to need to provide a bit more information here
06:34 louispan joined
06:34 <Myrl-saki> Yeah.
06:34 <Myrl-saki> This is ghcjs.
06:34 <Myrl-saki> Let me upload the log.
06:34 <Myrl-saki> http://ix.io/slg
06:35 Hunter1 joined
06:36 chobytes joined
06:36 <Myrl-saki> I'm trying without ghcjs, if that changes anything.
06:37 <Lokathor> http://lpaste.net/355096
06:37 <cocreature> huh that’s a weird error
06:37 <cocreature> sry not sure what’s going on here
06:37 <Myrl-saki> cocreature: It's fine. I'm wondering if it's because I'm using ghcjs.
06:38 hucksy joined
06:38 <Myrl-saki> Lokathor: Do lines 12-15 get shown in the documentation?
06:38 <cocreature> Myrl-saki: afaik the differences between ghcjs and ghc are far below the layer of the parser, so parse errors like this shouldn’t be specific to ghcjs. but trying to reproduce it using ghc is probably still a good idea
06:39 <Lokathor> Myrl-saki, nope, not at all
06:39 <Myrl-saki> Lokathor: FOr functions, how do you annotate the arguments?
06:39 <cocreature> line 1-3 and 8-9 will get shown in the docs
06:39 <cocreature> Myrl-saki: https://www.haskell.org/haddock/doc/html/ch03s02.html#idm140354810892448
06:39 <Lokathor> Myrl-saki, you can use the same "-- ^" comment markup and split the signature over more than one line
06:40 <Myrl-saki> Also happens with ghc.
06:40 <Myrl-saki> :(
06:40 Argue_ joined
06:40 <Myrl-saki> https://github.com/conal/MemoTrie/issues/10
06:40 <Myrl-saki> Exact problem lol
06:41 <cocreature> seems like you just need to use a newer version
06:41 xaimus joined
06:42 <Myrl-saki> Mhm.
06:42 <Myrl-saki> Trying 0.6.5.
06:42 whiteline joined
06:42 <Myrl-saki> How long does stack haddock take to engerate, and how large do the docs tend to be? (And how do I clean them up later)
06:43 prat joined
06:43 <prat> \help
06:44 richi235 joined
06:45 <Lokathor> Myrl-saki, longer the first time, stack rebuilds with docs enabled. After that, not too long
06:46 takle joined
06:46 <Lokathor> and you can just clear out the .stack-work/ directory to clean all your build files and docs and all that, or you can also clear just the docs if you look around inside
06:46 ubsan_ joined
06:47 Hunter1 joined
06:48 cynick joined
06:50 plutoniix joined
06:51 jer1 joined
06:53 takuan joined
06:54 plutoniix joined
06:56 takle joined
06:56 ner0x652 joined
06:58 plutoniix joined
06:59 iomonad joined
06:59 plutoniix joined
07:00 raichoo joined
07:00 zeroed joined
07:00 zeroed joined
07:01 <Myrl-saki> Lokathor: Is this API good? https://github.com/adrianparvino/reflex-bulma/blob/master/src/Reflex/Bulma/Grid.hs (This is how to use it: http://ix.io/sit )
07:01 <Myrl-saki> Lokathor: Sorry, didn't mean to ping you.
07:01 <Lokathor> i don't even know what i'm looking at :P
07:02 <Myrl-saki> Lokathor: Enforcing the usage of a function through RankNTypes.
07:02 <Myrl-saki> Literally the first time I used it.
07:02 <Lokathor> sounds beyond me
07:03 <Lokathor> I used runST once
07:03 cobreadmonster joined
07:04 iomonad joined
07:06 iomonad joined
07:06 eklavya joined
07:06 <Myrl-saki> Welp.
07:06 <Myrl-saki> That didn't actually work.
07:07 <Myrl-saki> I can just make a `forall s. (m (Const () s)`
07:07 <Myrl-saki> Back to the drawing board. :(
07:08 tsmish joined
07:08 mmn80 joined
07:09 pranz1 joined
07:09 mohsen_1 joined
07:09 <Myrl-saki> How about `forall p. ([Text] -> m a -> m (p a)) -> ((p a) -> a) -> m a`
07:09 plutoniix joined
07:10 takle joined
07:11 <Myrl-saki> I don't want to define a new monad just for this.
07:11 Xanather joined
07:11 augur joined
07:13 vlatkoB_ joined
07:14 <cocreature> Myrl-saki: why do you need a RankNType here in the first place? it seems like you are not making use of the fact that your function is polymorphic since you are only applying it once
07:14 wroathe joined
07:17 <Myrl-saki> cocreature: I'm pretty much just tryign what works and what doesn't.
07:18 <cocreature> Myrl-saki: adding a phantom type parameter via Const but then forcing it to be polymorphic doesn’t seem particularly useful but maybe I’m missing something here
07:18 sgronblo_ joined
07:19 seanparsons joined
07:19 <Myrl-saki> cocreature: Wait, you mean that it'd have worked without the forall?
07:19 sgflt joined
07:19 <cocreature> remove the Const and remove the forall
07:20 <Myrl-saki> cocreature: I want to force the usage of the passed function.
07:20 <cocreature> Myrl-saki: force what? and why?
07:21 <Myrl-saki> cocreature: http://ix.io/slr
07:21 butterthebuddha joined
07:21 <Myrl-saki> cocreature: It's hard to explain why.
07:22 plutoniix joined
07:23 jutaro joined
07:23 <cocreature> :t \f x y -> Const <$> (f x y)
07:23 <lambdabot> forall k (b :: k) a (f :: * -> *) t t1. Functor f => (t1 -> t -> f a) -> t1 -> t -> f (Const a b)
07:23 <cocreature> you’re not actually restricting something, I can just create the function you expect based on an arbitrary function
07:23 <Myrl-saki> cocreature: Yeah.
07:24 <Myrl-saki> cocreature: That's why I said Myrl-saki | That didn't actually work.
07:24 <Myrl-saki> I'm trying to do this instead.
07:24 <Myrl-saki> columns :: (MonadWidget t n, MonadWidget t m) => [Text] -> ((forall a. [Text] -> m a -> n a) -> n a) -> m a
07:24 <cocreature> sry I’m not going to be able to help you if I don’t know what your goal is
07:24 <Myrl-saki> To say the last. It's still not working. Lol.
07:24 <Myrl-saki> To say the least*
07:24 <Myrl-saki> cocreature: Let me try to explain.
07:25 <Myrl-saki> cocreature: `foo $ (\bar -> do {bar ...; bar ...; bar ... })`
07:26 <Myrl-saki> cocreature: I can't explain it very well lol
07:26 <Myrl-saki> cocreature: Basically, it should be that `bar` must be used to "postprocess" the wrapped monad.
07:27 <cocreature> what’s are the arguments to bar supposed to be?
07:27 <cocreature> s/what’s/what/
07:27 takle joined
07:27 <Myrl-saki> cocreature: I could have used `traverse bar` but that makes me lose the mutual thingy.
07:27 <Myrl-saki> cocreature: Right.
07:27 <cocreature> mutual thingy?
07:27 <Myrl-saki> cocreature: The argument to bar is the same monad as `foo`
07:28 <Myrl-saki> cocreature: `x <- m; y <- m1 x`
07:28 <Myrl-saki> cocreature: Or even mdo
07:28 <Myrl-saki> I was thinking of saying `mutual recursion` but not too sure if it was appropriate.
07:29 meba joined
07:29 <cocreature> you can’t enforce that the user does do {bar …; …} instead of bar (do …)
07:29 plutoniix joined
07:30 <Myrl-saki> cocreature: I want to enforce the user to do `do {bar ...; bar ...;} rather than `do {..., bar ...}`
07:31 newhoggy_ joined
07:31 <Myrl-saki> cocreature: (Every "root" must be `bar`)
07:31 <Myrl-saki> If that makes any sense.
07:32 plutoniix joined
07:33 <cocreature> maybe you’re looking for something like “f :: (forall n. (m a -> n a) -> n a) -> m a”?
07:33 seefischer joined
07:33 takle joined
07:34 <Myrl-saki> cocreature: Yeah, that's what I'm doing right now.
07:35 <Myrl-saki> cocreature: But I don't know how to unwrap the n.
07:35 <Myrl-saki> (How to produce an (n a -> m a))
07:35 <cocreature> well what do you want n to be?
07:36 ragepandemic joined
07:36 plutoniix joined
07:36 <Myrl-saki> cocreature: You probably think this is stupid, but n == m? :D
07:36 <cocreature> Myrl-saki: now we’re back to the point, where I don’t know what you’re actually trying to do :)
07:36 <Myrl-saki> cocreature: :P
07:36 <cocreature> Myrl-saki: I think you need to make some minimal example that demonstrates the API you’re trying to get and then we can talk about if and how you can get that
07:37 <cocreature> if you really want n == m, just use "id" but that’s hardly useful
07:38 Mortomes|Work joined
07:38 plutoniix joined
07:38 besenwesen joined
07:39 <* ski> . o O ( `n = m' )
07:39 thc202 joined
07:39 <cocreature> ski: n ~ m
07:39 <Myrl-saki> A bit of a segway. What does ~ do?
07:39 zeroed joined
07:39 beanbagula joined
07:39 <* ski> doesn't like that symbol chosen
07:39 <Myrl-saki> Does it make sure that you can interchange the 2?
07:40 iomonad joined
07:40 soniku joined
07:41 <Myrl-saki> http://ix.io/slu
07:41 <Myrl-saki> That's my current code so far.
07:42 <Myrl-saki> (That doesn't work.)
07:43 <ski> er, why did you add `m ~ n' in the type signature ?
07:43 <Myrl-saki> ski: In which?
07:43 <Myrl-saki> The top level?
07:44 <ski> yes
07:44 <ski> oh, and the `forall' is wrong
07:45 oisdk joined
07:45 <ski> unwrap :: (m ~ n, MonadWidget t m, MonadWidget t n) => m a -> n a
07:45 <ski> should be the same as
07:45 <cocreature> Myrl-saki: let’s take a step back. what is “columns” supposed to do on a conceptual level. it takes some css classes, that’s relatively clear. then it takes some function. what does that function represent?
07:45 plutoniix joined
07:45 <ski> unwrap :: MonadWidget t m => m a -> m a
07:45 <Myrl-saki> ski: Really? I think the forall is needed so that I can do `bar (return ()); bar (return 1)`
07:45 <ski> yes, but the `forall' is wrong
07:46 <ski> look aggain at what cocreature suggested
07:46 <Myrl-saki> cocreature: Right.
07:46 <Myrl-saki> cocreature: The function represents its direct descendant.
07:47 <ski> is there a reason why `column' has `classes' as a formal parameter ?
07:47 <ski> hmm
07:47 <ski> i suppose `m' is expecting it
07:48 <Myrl-saki> ski: To allow styling of individual column.
07:48 <ski> `m' will call `column' with a potentially different `classes' parameter ?
07:50 <Myrl-saki> Mhm.
07:50 augur joined
07:50 tromp joined
07:52 dm3 joined
07:52 plutoniix joined
07:53 <ski> Myrl-saki : oh, the `forall' is also in the wrong place ..
07:53 augur joined
07:54 takle joined
07:55 <Myrl-saki> I think I should make a cleaner API without the classes argument.
07:57 <Myrl-saki> http://ix.io/sly
07:57 plutoniix joined
07:57 <ski> anyway, i think `unwrap' has no real use here
07:58 <Myrl-saki> ski: Yep.
07:58 <jchia_1> I'm using typeclass A & type B from different hackage packages that I don't control. I want to have an A instance for B but avoid orphaned instances. I know I can wrap B in a newtype to do that but I want to avoid the boilerplate. How else can I do it safely? In seems that I could do it like how it's done in mono-traversable-instances (Data.MonoTraversable.Instances) & dlist-instances (Data.DList.Instances), but all that they seem to do
07:58 <jchia_1> is to use '-fno-warn-orphans' to disable the warning. Specifically, I want to make a Data.Store.Store instance for a named tuple field from Labels.
07:58 <ski> Myrl-saki : and `forall' is still wrong, and additionally in the wrong place, in the new paste
07:59 <Myrl-saki> ski: Basically, I think I can solve my problem if I can define `m a -> n a` and `n a -> m a` such that m and n are pretty much the same monad, but they won't unify with each other.
07:59 kazagistar joined
07:59 <ski> please take a look at
07:59 <ski> <cocreature> maybe you’re looking for something like “f :: (forall n. (m a -> n a) -> n a) -> m a”?
07:59 zeroed joined
07:59 saep joined
08:00 <ski> again, and see how (the essential part of) it differs from what you have in that paste
08:00 <Myrl-saki> ski: How do I define (m a -> n a) though?
08:00 Jesin joined
08:00 <ski> no need to
08:00 <ski> you already have
08:00 <ski> column :: (m ~ n, MonadWidget t n, MonadWidget t m) => m a -> n a
08:00 <Myrl-saki> Oh true.
08:00 <ski> which can be simplified to
08:01 <ski> column :: MonadWidget t m => m a -> m a
08:01 gehmehgeh joined
08:01 insitu joined
08:01 <ski> (the interesting thing happens with `m', not `columns')
08:01 <ski> (er, not `column'. i shouldn't confuse `column' and `columns' here ..)
08:03 <ski> .. but all this won't work unless you move the `forall' to its correct place. and also correct it in the other way i've been attempting to hint at
08:03 epsilonhalbe joined
08:03 <cocreature> I don’t know reflex so take this with a grain of salt, but it seems like Myrl-saki is trying to enforce that each individual widget is wrapped in “column”. the problem is that this doesn’t make sense since reflex doesn’t have a concept of individual widgets: the composition of widgets (via >>) is a new widget
08:04 Denthir joined
08:04 <cocreature> so you are either going to need to accept a list of widgets in which they can’t use MonadFix to reference each other or you deal with the fact that it’s up to the user to place “column” correctly
08:05 <cocreature> *in which case
08:05 acidjnk22 joined
08:05 <Myrl-saki> cocreature: I was able to use the List version, but I had problems with the result types.
08:06 <ski> is the composition of widgets (via `(>>)') a new *individual* widget, though ?
08:06 ccomb joined
08:06 <* ski> doesn't know `reflex', either
08:06 seanparsons joined
08:06 plutoniix joined
08:06 <cocreature> ski: you can’t inspect them to see a difference afaict
08:07 xcmw joined
08:07 <ski> (i.e. perhaps Myrl-saki have some notion of "individual widget" in mind that's meaningful to keep track of, even though `reflex' itself doesn't)
08:07 bkboggy joined
08:08 <ski> (.. well, there's many things you can't inspect, which you can reason about and keep track of, nonetheless)
08:11 plutoniix joined
08:12 <Myrl-saki> I honestly have no idea why this is working lol
08:12 <LiaoTao> Myrl-saki: That's my experience with Haskell in a nutshell
08:13 <Myrl-saki> If I use `MonadWidget t n` as a constraint in the Rank-2 forall, then it doesn't work?
08:13 <Myrl-saki> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => ([Text] -> m a -> n a) -> n a) -> m a
08:13 <Myrl-saki> I get an untoucheable error.
08:14 <Myrl-saki> Maybe I should ask the contributors for this case. This seems to be implementation detail now.
08:14 <cocreature> I don’t think the RankNTypes solution is going to help at all if I understand your problem correctly
08:15 plutoniix joined
08:15 <Myrl-saki> http://ix.io/slC
08:15 <Myrl-saki> http://ix.io/slD
08:15 oish joined
08:16 rndbt joined
08:16 <cocreature> you probably need to add “t” to the forall
08:17 suppi joined
08:17 <Myrl-saki> cocreature: That makes sense.
08:17 Aruro joined
08:18 <ski> i don't think so
08:18 mda1 joined
08:18 plutoniix joined
08:18 takle joined
08:19 <Myrl-saki> Doesn't work.
08:20 <ski> what's the code that generated that error ?
08:20 <ski> hm
08:20 <Myrl-saki> http://ix.io/slD
08:21 <ski> i mean, which version of `columns' ?
08:21 <Myrl-saki> This is my current code. http://ix.io/slG
08:21 <Myrl-saki> (For columns)
08:21 plutoniix joined
08:22 <Myrl-saki> It requires the inner a to be polymorphic?
08:23 epsilonhalbe left
08:23 <Myrl-saki> http://ix.io/slJ
08:23 <ski> it shouldn't
08:23 <Myrl-saki> That one compiles.
08:24 takle joined
08:24 beanbagu1 joined
08:25 eklavya joined
08:25 takle joined
08:26 lep-delete joined
08:28 <ski> otoh, i'm not sure why it isn't
08:28 <ski> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => ([Text] -> m () -> n ()) -> n ()) -> m ()
08:28 <ski> since you'll anyway be discarding all but the last `a'
08:29 <Myrl-saki> ski: Right.
08:29 ixxie joined
08:29 <Myrl-saki> ski: But I can compose the a out of the other types.
08:29 <Myrl-saki> Errr
08:29 <Myrl-saki> the other results.
08:30 <Myrl-saki> For example. `return [x, y]` where x and y are the result of the column.
08:30 <ski> aye
08:30 plutoniix joined
08:30 <Myrl-saki> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => ([Text] -> m b -> n b) -> n a) -> m a
08:30 <Myrl-saki> This one also errors.
08:30 <Myrl-saki> I think it has problems with `m b -> n b`
08:30 gienah joined
08:31 richi235 joined
08:31 <Myrl-saki> http://ix.io/slP
08:31 <Myrl-saki> Mark set [3 times]
08:33 joachifm joined
08:33 <ski> Myrl-saki : hm, yea, i was just thinking along those lines
08:33 <ski> you need a `forall b.'
08:33 plutoniix joined
08:34 ericsagnes joined
08:34 <ski> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => ([Text] -> m a -> n a) -> n a) -> m [a]
08:34 <Myrl-saki> ski: Right. But the problem gets moved back to the library's user.
08:35 <ski> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => (forall b. [Text] -> m b -> n b) -> n a) -> m [a]
08:36 <ski> hm
08:36 <ski> then `column' will have type `forall b. [Text] -> m b -> n b', iow it will be polymorphic in `b', so the caller of `column' will get to pick it
08:36 _sg joined
08:36 <ski> pondering whether that's a good thinge here or not
08:37 <Myrl-saki> I can do this though.
08:37 unK_ joined
08:37 <Myrl-saki> columns :: MonadWidget t m => [Text] -> (forall n. MonadWidget t n => (forall b. [Text] -> m b -> n b) -> n ()) -> m ()
08:37 <Myrl-saki> I think it doesn't know what to do with the last (n a)?
08:37 <ski> not sure whether you need that extra generality of `column'
08:38 <ski> well, to get `m [a]', you'd need to collect results, something. pondering whether that makes sense here (whether it's something that can be done)
08:39 <ski> your `page' example could collect .. but possibly that's not something you want a user of `columns' to have to do
08:39 plutoniix joined
08:40 <ski> one could probably do something with an output monad, to collect, inside `columns'
08:40 <ski> but it's not clear whether functionality like that would be desired/useful ?
08:41 systadmin joined
08:41 mmhat joined
08:41 <ski> Myrl-saki : btw, you could rename `a' to `b', in the type signature of `column', to better match the naming
08:42 eklavya_ joined
08:42 <Myrl-saki> ski: Ah. True. Thanks.
08:42 <ski> (iow, not confusing it with the `a' in the type signature of `columns')
08:42 Fairy joined
08:42 darjeeling_ joined
08:43 Yuras joined
08:44 joachifm joined
08:44 <kamyar> Hello again
08:44 <kamyar> please check my code: http://lpaste.net/355097
08:45 <Myrl-saki> ski: For now, I'll just set the constraint to MonadFix.
08:45 <kamyar> Ask any question
08:45 <kamyar> line 7 is the problem
08:45 <kamyar> rand_str contains a IO String
08:45 <Myrl-saki> ski: And see if there's something I can't do with it.
08:45 <kamyar> I just need to cann redis hset which in second argument gets ByteString
08:46 <kamyar> I am trying to use curried feature and use =<< operaor to feed it
08:46 <kamyar> What is the problem?
08:46 splanch joined
08:46 aloiscochard joined
08:49 <srhb> kamyar: Look at the expected type and the actual type. That's the relevant bit. Now convince yourself that the expression actually has the type of _actual type_
08:49 <srhb> kamyar: Once you've done that, remedy the expression to have expected type.
08:50 <srhb> kamyar: Ask if there's a step that doesn't make sense to you. :)
08:50 <kamyar> srhb: I think it is evident! I knwo it but how?
08:50 <srhb> kamyar: What is evident?
08:50 <kamyar> srhb: Your phrases!
08:50 <srhb> kamyar: Well, that's a start. :-)
08:51 <srhb> Do you agree that the argument *should* be a ByteString in order to typecheck?
08:51 <kamyar> srhb: I just do not know how to call a function with signature String -> ByteString -> ByteString -> IO x with an argument of type IO String
08:51 hurkan left
08:51 <srhb> kamyar: Indeed, you can't. You need a String.
08:52 <kamyar> srhb: String is easily converted to ByteString using pack,
08:52 <srhb> kamyar: Indeed, but you don't have a String to convert.
08:52 <srhb> kamyar: You have an IO String.
08:52 <kamyar> srhb: I need some kind of operator like <$> or =<< to feed the function with inner part of IO String
08:53 <srhb> kamyar: You could do that, but since you already have a do block with access to IO via liftIO, why not use it?
08:53 <kamyar> srhb: Just watch the next line which is correct!
08:53 Hunter1 joined
08:53 JagaJaga joined
08:53 <cobreadmonster> Does anyone have advice on constructing parsers?
08:53 <kamyar> srhb: How?
08:53 <srhb> kamyar: ie theString <- liftIO rand_str
08:53 <cobreadmonster> I can use parsec, but it's more like a tool than an algorithm.
08:53 <kamyar> srhb: Cool! Lets test
08:54 <cobreadmonster> I'm trying to parse something with a very loose grammar (like markdown) so I need to be crafty about designing my parser first.
08:54 rndbt left
08:56 Argue joined
08:56 aidecoe joined
08:56 phyrex1an joined
09:00 plot joined
09:00 fizbin joined
09:01 reynir1 joined
09:01 reynir joined
09:02 jabesed joined
09:02 reynir joined
09:04 raichoo joined
09:05 ichor joined
09:05 zeroed joined
09:05 <kamyar> srhb: Anything fixed! I just revised my code using ur guide! I am newbie!
09:06 twanvl joined
09:06 sgronblo joined
09:07 <srhb> kamyar: Welcome to Haskell then. :)
09:08 <kamyar> srhb: Wanna see my code and give me more guide?
09:08 Itkovian joined
09:08 taktoa joined
09:08 <srhb> kamyar: Feel free to leave a paste link, others might be able to help as well, especially with concrete questions.
09:08 <kamyar> srhb: Thanks!
09:09 eklavya joined
09:09 <kamyar> http://lpaste.net/355098
09:09 Guest55823 joined
09:10 <kamyar> please help me omit dummy prints! print "test" in line 61
09:10 ragepandemic joined
09:10 <kamyar> and print $ latitude in line 69
09:10 <kamyar> I just dunno how to return a IO ()
09:11 <srhb> kamyar: return ()
09:11 <srhb> I'm a bit confused by the lift there though.
09:11 <cobreadmonster> Any advice?
09:12 Hunter1 joined
09:12 <kamyar> srhb: Thanks! Fixed!
09:12 epsilonhalbe joined
09:12 atomi joined
09:13 <kamyar> srhb: Is it a good practice to use IO monad for such functions? saving in redis
09:13 <srhb> cobreadmonster: I think the question is currently too broad to give any helpful advice.
09:13 <cobreadmonster> srhb: markdown's corner cases keep fucking me up.
09:13 <cobreadmonster> So that's a real problem.
09:13 <srhb> kamyar: runRedis :: Connection -> Redis a -> IO a -- so you really can't do much else.
09:13 <cobreadmonster> I can't do anything other than assume and back track and I was wondering if there's a cleaner way to do it.
09:13 <kamyar> srhb: I mean saveLocation and saveToken in my code
09:14 <kamyar> srhb: Thanks! I guessed so
09:14 <srhb> cobreadmonster: Perhaps take a look at how Pandoc parses markdown.
09:14 <kamyar> srhb: Is my code good for a newbie?
09:14 <srhb> cobreadmonster: I imagine that's about as clever as you can get about it.
09:14 <srhb> kamyar: I think it looks OK. :)
09:15 <kamyar> srhb: Thnk you so much! Feel good now!
09:17 <cobreadmonster> srhb: That's a real mess.
09:17 <cobreadmonster> I was hoping for something cleaner, because my langauge isn't going to be as complicated.
09:18 <cobreadmonster> But I guess not.
09:18 ixxie joined
09:18 Kreest__ joined
09:18 epsilonhalbe left
09:19 turist joined
09:20 niluje joined
09:20 rann joined
09:21 noumenon joined
09:22 grayjoc joined
09:25 henriksod joined
09:29 turist joined
09:29 meba joined
09:30 newhoggy joined
09:32 connrs joined
09:33 atomi joined
09:36 newhoggy joined
09:37 bollu joined
09:38 gmcabrita joined
09:38 Argue_ joined
09:41 saurabhnanda joined
09:42 soniku joined
09:42 newhoggy joined
09:42 richi235 joined
09:47 Wizek joined
09:48 newhoggy joined
09:49 mirpa joined
09:50 Denthir joined
09:50 cloudhead joined
09:50 turist joined
09:50 litchblade joined
09:51 biglambda joined
09:55 sssilver joined
10:05 beanbagu1 joined
10:09 mohsen_ joined
10:10 <mohsen_> Hi, I'm trying to run this simple program: add x y = x+y
10:10 <mohsen_> main = putStrLn (add 2 3)
10:10 <mohsen_> But I get this error: https://ptpb.pw/HG-g
10:10 <Athas> mohsen_: putStrLn takes a String as argument, but your 'add' function returns a number.
10:11 <mohsen_> Athas: Okay, how should I convert it?
10:11 <Athas> Due to type inference, the compiler assumes that what you mean is that the 'add' function takes (and returns) a String, which then confuses it further.
10:11 <Athas> mohsen_: use the 'show' function to turn a number into a String.
10:12 <pacak> Or use print instead of putStrLn
10:12 <pacak> :t print
10:12 <lambdabot> Show a => a -> IO ()
10:12 <pacak> :t putStrLn
10:12 <lambdabot> String -> IO ()
10:12 <Athas> However, you may still get a warning due to an ambiguity: you are not specifying exactly *which* numeric type you want to use.
10:12 <Athas> That 2 and 3 could be an Int, an Integer, a Double, or anything else that can be added.
10:12 <Athas> It will default to Integer, however.
10:12 <mohsen_> Athas: Can I also define the function so that it takes a number but returns a string?
10:12 <Athas> Yes, sure, just call 'show' inside 'add'.
10:13 <pacak> But it won't be add anymore...
10:13 <ski> call it `showAdd' ?
10:13 <mohsen_> Hmmmm
10:13 Itkovian joined
10:13 <ski> (you can keep the old `add', if you want to)
10:13 <mohsen_> Another question, should I generally define the type reference of functions or let the compiler determine them?
10:14 <pacak> Type signatures?
10:14 <mohsen_> I mean type definition like this: String -> IO()
10:14 <pacak> Add them to all the toplevel things
10:14 <ski> for top-level definitions in a module, most people prefer writing explicit type signatures
10:14 <mohsen_> Hmmm, what do you mean by toplevel?
10:14 <Athas> mohsen_: your choice, but current (compiler-enforced) style is type annotations for all top-level definitions.
10:14 <pacak> Error messages will be better if you mess things up.
10:14 <Athas> 'Top-level' is anything that is not indented, roughly.
10:14 <ski> you can also have local definitions, only visible inside some "parent" definition
10:14 <srhb> Athas: Compiler enforced?
10:15 <Athas> srhb: ghc -Wall warns about it.
10:15 <srhb> I had no idea.
10:15 <pacak> Using -Wall is probably a good idea.
10:15 <srhb> I do. :-)
10:15 <* ski> thinks John Hughes mostly prefers as few type signatures as possible
10:16 <mohsen_> Thanks guys
10:16 <Athas> ski: it seems like people from the early days of FP were quite enthusiastic about not having type signatures.
10:16 <ski> (istr he said something to that effect)
10:16 <Athas> I think it's a relic of trying to compete with Lisp in concision.
10:16 <cloudhead> any idea why compilation of Lucid html templates might be really really slow?
10:18 <pacak> cloudhead: Optimizations?
10:19 <cloudhead> pacak: I mean, why would it be slower than compiling "regular" haskell code is my question
10:19 <Athas> It uses Template Haskell, right?
10:19 <pacak> cloudhead: TH
10:20 <cloudhead> ah does it?
10:20 <Athas> Template Haskell is when you kick up your feet and pour yourself a cup of tea after starting the compiler.
10:20 <cloudhead> how can I find out
10:20 <cloudhead> I'm not sure why it would need TH
10:20 <pacak> Athas: Nah, TH can be fast.
10:21 <mikeplus64> is there a state monad (in a library somewhere) with no result? i.e. newtype NonStateT m s a = NonState (s -> m s)
10:21 eliasr joined
10:21 <dibblego> it used to be called Pointed
10:21 <pacak> In fact I use TH in one project to make compilation faster - it derives typeclass instance that otherwise gets derived by generics
10:22 <pacak> When you have 200+ fields - generics are REALLY slow.
10:22 mirpa_ joined
10:23 seanparsons joined
10:27 mirpa joined
10:28 <cocreature> lucid doesn’t kneed TH afaik
10:28 newhoggy joined
10:30 <cloudhead> cocreature: yeah there is no reason for it to use TH
10:30 <cloudhead> I'm not sure what is affected the compile time
10:31 <cloudhead> affecting*
10:31 <cocreature> cloudhead: what are you comparing it to?
10:31 <cloudhead> it seems to be built on top of blaze-builder, so maybe this is slow for blaze too
10:32 <cloudhead> cocreature: my average module... when it compiles the lucid views, it takes almost 10s for about 400 lines of code
10:32 <cloudhead> I've never seen something take so long for so little code before
10:32 <cocreature> cloudhead: what options are you passing to GHC?
10:32 <cocreature> cloudhead: in particular, does it also happen if you use -O0?
10:33 fakenerd joined
10:33 <cloudhead> I'm only passing warning-related options
10:33 <cloudhead> and I have a few extensions enabled
10:33 <cloudhead> let me try that
10:34 Gurkenglas joined
10:34 Shock_ joined
10:35 t7 joined
10:35 oish joined
10:36 simukis_ joined
10:36 <cloudhead> cocreature: yeah, using the --fast flag (I'm using stack) cuts it down to 1-2s from 10s
10:37 <cloudhead> I wonder though why specifically this module
10:38 <cocreature> cloudhead: 10s seems slow enough that it might be worth investigating which part of your code is causing the slowdown and make a ghc bug report out of it
10:39 <cloudhead> cocreature: ok, will try to isolate it :)
10:39 netheranthem joined
10:40 <cocreature> cloudhead: maybe try building it using an older version of GHC, e.g. 7.10. regressions have a pretty good chance of getting fixed
10:40 newhoggy joined
10:41 <cloudhead> cocreature: ah yes, good idea
10:42 biglambda joined
10:43 plutoniix joined
10:43 NyanPasu joined
10:44 kuribas joined
10:45 mzf joined
10:47 augur joined
10:48 Aruro joined
10:49 saurabhnanda joined
10:49 atomi joined
10:52 tromp joined
10:53 bennofs joined
10:54 yellowj joined
10:55 seanpars1 joined
10:56 permagreen joined
10:56 latro`a joined
10:57 jer1 joined
10:59 mmachenry joined
10:59 insitu joined
10:59 dejanr joined
11:03 Snircle joined
11:03 obiwahn joined
11:07 chlong joined
11:11 JuanMiguel joined
11:12 systadmin joined
11:13 crave joined
11:13 sillyotter joined
11:15 romank joined
11:16 romank joined
11:16 Argue__ joined
11:17 <cocreature> we still don’t have a way to just overload integer literals without implementing all of Num or did I miss something?
11:17 soniku joined
11:17 Aruro joined
11:19 romank joined
11:21 thunderrd_ joined
11:24 epsilonhalbe joined
11:25 bjz joined
11:27 shyn joined
11:29 zariuq joined
11:30 meba joined
11:31 sgronblo joined
11:34 newhoggy joined
11:35 wroathe joined
11:35 DocWinter joined
11:35 rossberg joined
11:36 dfeuer joined
11:36 Hunter1 joined
11:37 mkwia joined
11:37 danvet joined
11:38 Fendor joined
11:39 <wz1000> cocreature: You can use -XRebindableSyntax and write your own fromInteger.
11:39 binaryplease joined
11:39 mmn80 joined
11:40 <cocreature> wz1000: ah good point, thanks
11:40 newhoggy joined
11:40 asmyers joined
11:40 zeroed joined
11:40 zeroed joined
11:43 xcmw joined
11:45 wroathe joined
11:45 newhoggy joined
11:45 Filip_ joined
11:46 anuxivm joined
11:46 systadmin joined
11:46 romank joined
11:46 Arizona6882 joined
11:47 kritzcreek joined
11:50 mkwia left
11:50 Shock_ joined
11:51 splanch joined
11:51 isBEKaml joined
11:51 sleblanc joined
11:51 acarrico joined
11:52 mbuf joined
11:52 splanch_ joined
11:53 newhoggy joined
11:55 splanch__ joined
11:55 stevenxl joined
11:56 stevenxl joined
11:56 stevenxl joined
11:56 splanch joined
11:57 <stevenxl> Hi folks. If I have the following data type declaration: data Fake = Lie | AlternativeFact String Int, can I describe the type Fake as both a sum type, since the values can be Lie or AlternativeFact String Int, as well as a product type, since the data constructor AlternativeFact requires two type arguments?
11:58 SpinTensor joined
11:59 Fendoer joined
11:59 romank joined
12:00 <Arizona6882> L + A (S * I) ?
12:01 <Arizona6882> isnt it just a sum type on top?
12:01 <kuribas> yes, it's like Either Lie (String, Int)
12:02 nighty-- joined
12:04 nomicflux joined
12:05 wroathe joined
12:05 <stevenxl> I'm just confused because data Bool = False | True is a sum type. data Person = Person String Int is a product type. if I combine these to form data Nonesense = True | Person String Int, how would we describe Nonesense?
12:05 <cocreature> ADTs in Haskell are always sums of products
12:05 roconnor joined
12:05 <cocreature> a type with a single constructor is just a boring sum just like a constructor with no arguments is a boring product
12:06 paolino joined
12:08 jleon joined
12:08 <stevenxl> Oh OK. So sum type just means single data constructor, even if that data constructor takes two type arguments?
12:08 tromp joined
12:08 pungi-man joined
12:10 <cocreature> you construct the sum type of a set of types my making one constructor for each of those types. if your set of types contains just one type, then the sum type of that is isomorphic to that single type
12:10 forgottenone joined
12:11 nomicflux joined
12:12 Argue_ joined
12:12 HoierM joined
12:13 <stevenxl> hm.. OK. Thank you. I'll have to dissect that sentence a bit, but that gives me a direction to look in.
12:13 <stevenxl> Thanks
12:13 tomphp joined
12:13 <cocreature> stevenxl: not that Person String Int is isomorphic to Person (String, Int)
12:14 romank joined
12:14 Itkovian joined
12:15 <cocreature> maybe that makes it a bit clearer how you’re first taking the product of String and Int to get (String, Int) and then the sum of () and (String, Int) to get "data Nonesense = True () | Person (String, Int)" which is then isomorphic to "data Nonesense = True | Person String Int"
12:15 <srhb> stevenxl: In case you didn't see it yet, you can also think of it as the number of values encompassed. Each time you introduce a new data constructor (ie Foo a | Bar b) you are adding to the number of terms. There are now (the number of terms of type a) plus (the number of terms of type b)
12:16 jabpe joined
12:17 sepp2k joined
12:18 tomphp joined
12:19 <Gurkenglas> Does some stack command add the source of all dependencies to the project? (So intero can jump to the definitions)
12:19 nadirs joined
12:20 thetourist joined
12:21 <bennofs> Gurkenglas: stack already stores all the unpacked source code somewhere in ~/.stack iirc, but intero does not yet support that I believe(?)
12:21 <bennofs> Gurkenglas: look at ~/.stack/indices/Hackage/packages
12:25 eacameron joined
12:25 zero_byte joined
12:25 wroathe joined
12:26 Alex___ joined
12:26 isqad joined
12:26 <isqad> Hello, world!
12:26 fruittec joined
12:27 epsilonhalbe left
12:30 plutoniix joined
12:30 sdothum joined
12:30 <Gurkenglas> https://github.com/cydparser/demo-emacs-haskell has a block of code under "1. Move any preexisting Emacs configurations". How do I run it?
12:31 plutoniix joined
12:32 <cocreature> Gurkenglas: that’s sh
12:33 newhoggy joined
12:33 <Gurkenglas> So, uh, I suppose that means I save it in a file with ending .sh and do "sh < thatfile.sh"? Does that work on Windows?
12:33 plutoniix joined
12:34 Elish joined
12:34 <cocreature> windows does not have a unix shell by default iirc so it probably won’t work
12:34 <cocreature> you can install bash on windows
12:35 <Gurkenglas> emacs has a shell thing if you do "M-x shell". Can I use that?
12:35 <cocreature> I have no idea what exactly M-x shell does, somaybe? :)
12:35 drcode joined
12:35 <cocreature> *so maybe
12:36 plutoniix joined
12:37 JeanCarloMachado joined
12:39 cpennington joined
12:39 plutoniix joined
12:40 systadmi1 joined
12:41 binaryplease1 joined
12:41 plutoniix joined
12:41 newhoggy joined
12:43 plutoniix joined
12:45 zariuq joined
12:45 bigos joined
12:46 mekeor joined
12:47 erikd joined
12:47 DrMentats joined
12:47 selthas joined
12:48 selthas joined
12:49 <paolino> hi, the type b a can be matched against type family B a so that b becomes B ?
12:49 <na_th_an> close
12:49 <paolino> not sure the way to express it
12:50 <paolino> quantify over the family ?
12:50 selthas joined
12:50 selthas left
12:50 na_th_an left
12:50 <mekeor> paolino: maybe give an example to illustrate your question?
12:51 m1ng0sfear joined
12:51 drcode joined
12:51 <paolino> (forall (u' :: Role) . State AcceptanceT u' a -> b (Opponent u') a) -> State s u a -> Either (b Taker a) (b Giver a)
12:52 <paolino> this doesn't compile for b cannot match a type family name
12:52 Profpatsch joined
12:52 <paolino> ehm, it doesn't run
12:52 <paolino> it compiles
12:53 takle joined
12:53 <paolino> as it is
12:54 drcode joined
12:54 <paolino> but if I try to match b it fails because b is Part in Couldn't match expected type ‘b (Opponent u') a’
12:54 <paolino> with actual type ‘Part (Opponent u') a’
12:55 <paolino> so the compiler cannot set b to Part
12:55 <paolino> that's my understanding
12:55 Wizek_ joined
12:57 <paolino> so my question is if it's because Part is a TF or something else
12:59 drcode joined
13:00 Achylles joined
13:00 newhoggy joined
13:01 plot joined
13:01 Achylles joined
13:01 fizbin joined
13:03 Achylles joined
13:03 <paolino> mekeor, http://lpaste.net/355105
13:04 Kreest__ joined
13:04 ner0x652 joined
13:05 godfrey joined
13:06 drcode joined
13:06 takle joined
13:06 cdg joined
13:06 iAmerikan joined
13:07 <godfrey> anyone knows how to make a type that only contains value of a sequence in haskell?
13:07 sellout- joined
13:07 <godfrey> e.g. a type that can only contain even numbers
13:08 oish joined
13:10 heurist` joined
13:11 mohsen_1 joined
13:11 takle joined
13:12 Boomerang joined
13:13 soniku joined
13:14 <srhb> godfrey: Actually constraining this at the type level needs dependent types, and it's tricky.
13:14 <srhb> godfrey: If you don't absolutely need this, you are better off using a smart constructor to prevent such values from being generating in user-facing code.
13:15 <godfrey> ummmmmm
13:15 fotonzade joined
13:15 <srhb> godfrey: (ie. hide the actual Even constructor and have a mkEven :: Integer -> Maybe EvenInteger)
13:15 <godfrey> I am just wondering if it's possible to achieve this in haskell
13:15 <srhb> godfrey: It is, though it's not easy. :)
13:15 <srhb> godfrey: Good languages for this sort of thing are Agda, Idris and friends.
13:15 <godfrey> yeah I know that trick
13:16 <godfrey> hiding the constructor and using Maybe type
13:16 <srhb> Right.
13:16 malorie joined
13:16 Yuras joined
13:16 <srhb> If you absolutely want to try, you'll need to do something like a Nat type which only has even numbers. Ie. inductively define it to be either Zero or Succ (Succ n) or something like that.
13:17 <srhb> Well, at least that's one approach/
13:17 <godfrey> lol
13:17 <godfrey> do you know any place that I can look up some material about this ?
13:18 JeanCarloMachado joined
13:18 bollu joined
13:19 <srhb> godfrey: Here are some approaches, one involving liquid haskell: https://www.reddit.com/r/haskell/comments/225j2w/how_would_you_define_a_type_for_even_integers/
13:19 ilyaigpetrov joined
13:20 Destol joined
13:21 <godfrey> kk
13:21 <godfrey> srhb: many thanks ;D
13:21 dcoutts_ joined
13:22 saurabhnanda joined
13:22 <srhb> godfrey: I will also recommend trying it in Agda afterwards for comparison :)
13:22 <godfrey> sure lol
13:23 beanbagu1 joined
13:24 Glooomy joined
13:24 justin2 joined
13:24 gugah joined
13:25 takle joined
13:25 Yuras joined
13:26 JuanMiguel joined
13:26 winmillwill joined
13:29 <Gurkenglas> I got http://lpaste.net/3532185850169262080 from following https://github.com/cydparser/demo-emacs-haskell from inside emac's shell. I'm on Windows. I have admin rights. What do? (At the end it's complaining about lack of permissions, that shouldn't happen, right?)
13:31 xcmw joined
13:33 newhoggy joined
13:33 mizu_no_oto_work joined
13:33 `^_^v joined
13:36 ystael joined
13:36 jangsutsr joined
13:36 mithrandeer joined
13:37 yellowj joined
13:37 ystael joined
13:37 m1ng0sfear joined
13:38 richi235 joined
13:39 Tesseraction joined
13:39 prizim joined
13:41 ChristopherBurg joined
13:43 meba joined
13:43 newhoggy joined
13:43 flatmap13 joined
13:43 <Gurkenglas> (Simply executing the command again made it work. ...)
13:44 robatosan joined
13:45 <jophish> Does anyone else get really odd behaviour in ghci when editing overlong lines?
13:45 romank joined
13:45 <jophish> basically, when a line extends past the length of my terminal it becomes really garbled
13:46 <MarcelineVQ> I get that in my shell sometimes, makle sure it's not a terminal issue before a ghci one if you can
13:46 <jophish> ah, I've found the issue
13:47 <jophish> I had this: :set prompt "ESC[34mλ> \ESC[m"
13:47 mohsen_ joined
13:47 <jophish> I think that ghci was taking the length of this string incorrectly
13:47 thetourist joined
13:47 <Tuplanolla> I've had that happen on RHEL without any special characters, jophish.
13:48 <jophish> the lambda seems fine, it's just the coloring that breaks it for me
13:48 <Tuplanolla> I think it was a terminal emulator issue where line wrapping worked incorrectly.
13:49 mmachenry joined
13:51 <jophish> ah, wrapping the escape codes with \001 and \002 fixed it
13:51 <jophish> :set prompt "\001\ESC[34m\002λ>\001\ESC[m\002 "
13:51 thallada joined
13:52 tcsavage joined
13:52 jabesed joined
13:52 yellowj joined
13:53 jer1 joined
13:53 hoknamahn joined
13:54 panovia joined
13:55 newhoggy joined
13:56 eschnett joined
13:56 JeanCarloMachado joined
13:57 Aruro joined
13:58 vlatkoB joined
13:58 dsh joined
13:58 descender joined
13:59 montik joined
13:59 theelous3 joined
13:59 cdg joined
14:03 eazar001 joined
14:05 drcode joined
14:05 newhoggy joined
14:06 BartAdv joined
14:07 drcode joined
14:07 obiwahn joined
14:08 raichoo joined
14:09 tromp joined
14:10 plot joined
14:11 systadmi1 joined
14:11 mgaare joined
14:12 richi235 joined
14:12 cloudhead joined
14:13 fresheyeball joined
14:13 <fresheyeball> quick question
14:13 <fresheyeball> lets say I need to run the same IO action over and over until a specific value is returned
14:13 <fresheyeball> I know how to do this with hand recursion, but is there a better way?
14:14 <Gurkenglas> Trying to use intero. Here's an emacs messages buffer. http://lpaste.net/4267388761236570112 Trying to use intero's M-. feature to jump to a definition adds invalid argument lines to that buffer. There are four chronologically ordered times that this worked, didnt work, worked and didnt work. They are iirc pairwise separated by at least one emacs restart. What do I do about this?
14:14 newhoggy joined
14:14 <fresheyeball> I'm thinking kind of a Monadic until function
14:14 <fresheyeball> untilM :: (a -> Bool) -> m a -> m [a]
14:15 asmyers joined
14:15 seventh-chord joined
14:15 anRch joined
14:19 <jophish> fresheyeball: you might be interested in this package https://hackage.haskell.org/package/monad-loops-0.4.3/docs/Control-Monad-Loops.html
14:19 thetourist joined
14:20 oleo joined
14:20 simcity2000 joined
14:20 NikolajK joined
14:21 schaeffer left
14:22 JeanCarloMachado joined
14:22 bollu joined
14:23 newhoggy joined
14:23 crobbins joined
14:23 dfeuer joined
14:25 a3Dman joined
14:26 systadmin joined
14:27 LordBrain joined
14:27 wroathe joined
14:27 snowalpaca joined
14:27 snowalpa_ joined
14:29 HarveyPwca joined
14:29 saurabhnanda joined
14:30 iAmerikan joined
14:31 osa1 joined
14:31 osa1 joined
14:34 newhoggy joined
14:35 mbw joined
14:37 yellowj joined
14:37 romank joined
14:37 cyborg-one joined
14:38 sampuka joined
14:39 drcode joined
14:39 Argue joined
14:40 ctag joined
14:40 insitu joined
14:42 michbad joined
14:42 erisco joined
14:43 agjacome joined
14:43 newhoggy joined
14:43 {emptyset} joined
14:44 k0001 joined
14:44 thetourist joined
14:44 erikd joined
14:44 armyriad joined
14:45 robatosan joined
14:48 <mbw> Hi everyone. I wanted to ask a few questions about Repa, and intended to do so either on SO, Reddit or haskell-cafe. Unfortunately, Ben Lippmeier (the author of Repa) hasn't been online on SO since 2014, and from what I found out he's busy with other stuff now. On the other hand, my question might actually be more general than that, and has become more lengthy than I intended. So before I post it anywhere, I
14:48 <mbw> would appreciate some input on this: Where to post it, whether it is clear what I'm asking or if it is just a waste of time. Any advice is appreciated - even if you don't have much experience with Repa, since it might just as well be a more general exercise in program transformation or equational reasoning. It can be found here: http://lpaste.net/355107 . Thanks in advance for any advice you might have!
14:48 MDA2 joined
14:48 drcode joined
14:48 rom1504 joined
14:50 sgronblo joined
14:50 ninjazoete joined
14:50 soLucien joined
14:52 bf_ joined
14:52 <bf_> Hi everyone
14:52 saep joined
14:52 <bf_> I have a question about encoding in ghc/base
14:54 <bf_> I want ghc/base to use the default encoding scheme (user's locale) but with the //ROUNDTRIP feature enabled
14:54 <bf_> How do I do that?
14:55 newhoggy joined
14:57 dmwit joined
14:59 <geekosaur> https://downloads.haskell.org/~ghc/8.0.2/docs/html/libraries/base-
14:59 Lokathor joined
15:01 splanch joined
15:02 <fresheyeball> is there a function to cycle a list?
15:02 <fresheyeball> [1,2,3] -> [2,3,1] ?
15:02 uglyfigurine joined
15:02 <byorgey> fresheyeball: no
15:02 <Tuplanolla> There's one to do that infinitely, fresheyeball.
15:02 <srhb> fresheyeball: Usually people just take and drop the relevant parts after cycling (repeating endlessly) the original list
15:03 al-damiri joined
15:03 Denthir joined
15:03 <byorgey> > drop 1 . take 3 . cycle $ [1,2,3]
15:03 <lambdabot> [2,3]
15:03 <byorgey> hehe, whoops
15:03 <byorgey> > take 3 . drop 1 . cycle $ [1,2,3]
15:03 <lambdabot> [2,3,1]
15:04 <fresheyeball> :t cycle
15:04 pmade joined
15:04 <lambdabot> [a] -> [a]
15:04 <byorgey> > cycle [1,2,3]
15:04 <fresheyeball> so what does cycle do?
15:04 <xa0> http://lpaste.net/revision/98916 i have this problem with postgresql-simple, anyone know why?
15:04 <lambdabot> [1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2...
15:04 <fresheyeball> oic
15:04 <erisco> I had a nice way to find the rotations... let me see if I can find it again
15:04 splanch_ joined
15:04 <lyxia> mbw: a markdown gist would help with formatting, then I'd just put it on reddit
15:04 newhoggy joined
15:04 <srhb> bf_: I don't think you can adjust what GHC reads source files as. I think it'll just be UTF8 always, but you can ask in #ghc
15:05 <erisco> ah yes, that is it... first you find the partitions and then you can find the rotations
15:05 <c_wraith> what about the "zipWith const" trick?
15:05 splanch__ joined
15:05 <c_wraith> That's a really important trick for maintaining laziness!
15:05 <geekosaur> bf_, srhb, the Haskell report specifies that Haskell source is UTF8
15:05 systadmin joined
15:05 <fresheyeball> let spinby x xs = take (length xs) $ drop x $ cycle xs
15:06 <erisco> > partitions [1,2,3]
15:06 <lambdabot> [([],[1,2,3]),([1],[2,3]),([1,2],[3]),([3,2,1],[])]
15:06 <erisco> > rotations [1,2,3]
15:06 <lambdabot> [[1,2,3],[2,3,1],[3,1,2],[3,2,1]]
15:06 <fresheyeball> Oooo
15:06 <Tuplanolla> The last one is bogus.
15:06 <fresheyeball> rotations xs !! 1
15:06 <kuribas> > zipWith const [5..] [1..5]
15:06 <lambdabot> [5,6,7,8,9]
15:07 <c_wraith> fresheyeball: "take (length xs)" is too strict. use the zipWith const trick instead. :)
15:07 <fresheyeball> > rotations [1,2,3] !! 1
15:07 <mbw> lyxia: I haven't done this before. gists are a git thing, right? It would be my first reddit post also. Since you seem to have read it, was it clear to you?
15:07 <lambdabot> [2,3,1]
15:07 <erisco> I can give you the source or let you figure it out... if you like that solution
15:07 <lyxia> xa0: the root module only exports FromRow without its method. you can import Database.PostgreSQL.Simple.FromRow
15:07 <fresheyeball> kuribas: how? I don't have a bounded thing, I just have a list of a
15:07 <xa0> lyxia: ah! thanks!
15:08 oleo_ joined
15:08 splanch joined
15:08 <fresheyeball> > let spinBy x xs = zipWith const [length xs..] (cycle xs)
15:08 <lambdabot> <no location info>: error:
15:08 <lambdabot> not an expression: ‘let spinBy x xs = zipWith const [length xs..] (cycle...
15:09 <fresheyeball> I guess, what is too strict about my solution?
15:09 <c_wraith> fresheyeball: length forces the entire list
15:09 oleo_ joined
15:09 <Tuplanolla> > let xs = [1, 2, 3] in all (`isInfixOf` cycle xs) (rotations xs) -- This should hold, erisco.
15:09 dlight joined
15:09 <lambdabot> mueval: ExitFailure 1
15:09 JeanCarloMachado joined
15:10 <erisco> Tuplanolla, I know it isn't all of them
15:10 <c_wraith> > let rotate n xs = zipWith const (drop n $ cycle xs) xs in rotate 10 [1..]
15:10 <erisco> Tuplanolla, there is a specific reason as to why
15:10 <lambdabot> [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,...
15:10 <c_wraith> fresheyeball: That wouldn't work with the length variant
15:10 splanch_ joined
15:12 eklavya joined
15:12 <fresheyeball> c_wraith: is it possible to do this operation on an infinite list?
15:12 <dolio> erisco: [3,2,1] isn't a rotation of [1,2,3] at all. And ([3,2,1], []) isn't a partition of [1,2,3].
15:12 <fresheyeball> don't we need to know the end of the list?
15:12 <c_wraith> fresheyeball: nope!
15:12 <fresheyeball> ok so let me see how you would write this
15:12 <c_wraith> fresheyeball: I just did?
15:12 <fresheyeball> such that :: Int -> [a] -> [a]
15:12 splanch__ joined
15:13 <c_wraith> fresheyeball: I just did. Look up
15:13 <bf_> geekosaur: thanks
15:13 <erisco> dolio, under a different specification, sure. I am just offering what I had
15:13 newhoggy joined
15:14 Xanather joined
15:14 <bf_> srhb: no I meant for normal IO especially file names and stuff
15:14 <fresheyeball> c_wraith: sorry I don't see it
15:14 <fresheyeball> I see you referencing the zipWith const trick
15:14 <fresheyeball> but I don't see how to use that without also forcing the list with length
15:14 splanch joined
15:15 <fresheyeball> even in the abstraction, I am having troubling seeing how you could rotate an infinite list
15:15 bf_ left
15:15 <c_wraith> > let rotate n xs = zipWith const (drop n $ cycle xs) xs in rotate 10 [1..] -- this exact thing before the comment that I entered above?
15:15 <lambdabot> [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,...
15:15 pmade joined
15:15 splanch_ joined
15:16 <nshepperd> well, one can question whether an infinite list that is rotated really counts
15:16 <c_wraith> > let rotate n xs = zipWith const (drop n $ cycle xs) xs in rotate 10 [1..12]
15:16 <lambdabot> [11,12,1,2,3,4,5,6,7,8,9,10]
15:16 <c_wraith> I mean, it's definitely a rotate function.
15:16 mounty joined
15:17 <nshepperd> since you can't find [1..10] at the "end" of an infinite sequence
15:17 <Tuplanolla> I suddenly forgot how to write the pointless form of `\ x -> f (g x) x`.
15:17 <c_wraith> It works maximally sensibly.
15:17 <c_wraith> It produces output on the assumption it'll eventually work.
15:17 beanbagu1 joined
15:17 <c_wraith> Which is much better than just exploding.
15:18 <mbw> (Haskellers and their lists...)
15:18 <nshepperd> Tuplanolla: i bet it contains <*>
15:18 <Gurkenglas> Tuplanolla, g >>= f
15:19 <lyxia> mbw: yeah I got most of it though I only skimmed it. gist is a good place to put lots of text if you don't have a blog, for the formatting.
15:19 <c_wraith> I mean, from a program's standpoint, what's the difference between an infinite list and a list of all Int on 64-bit ghc? You'll never iterate through either.
15:19 nscott76 joined
15:19 xcmw joined
15:19 <c_wraith> Best to produce output immediately
15:19 bencryption joined
15:19 <Tuplanolla> Ah, yes.
15:20 <dolio> You can even prove it's "at the end".
15:20 <mbw> lyxia: So if I got it right, I put the whole thing in the gist, and on Reddit instead of Post Text I use Post Link?
15:20 <dolio> Where that means that there is a list l such that 'l ++ [1..10]' is what you get.
15:20 <mbw> lyxia: Also, I don't think I am using the term "equational reasoning" correctly, since it is used in the context of proving things. Am I wrong?
15:21 newhoggy joined
15:21 eacameron joined
15:22 NikolajK1 joined
15:22 <Tuplanolla> So indeed `rotate n = drop n . cycle >>= zipWith const`.
15:23 <lyxia> mbw: Yeah taht's how you do it. Your use of "equational reasoning" it looks fine.
15:23 teggi joined
15:23 Noldorin joined
15:24 fresheyeball joined
15:25 <Gurkenglas> Now find a version of rotate n that uses O(n) space.
15:25 <mbw> lyxia: Ok then I will try to do it this way. Hopefully something useful comes out of this. Now I just need a descriptive title...
15:25 trism joined
15:25 <c_wraith> Gurkenglas: my version does. :P
15:25 <erisco> dolio, I went back over it and the reversal of the last partition was indeed a mistake. Thanks!
15:25 <fresheyeball> c_wraith: sorry I crashed my box
15:25 <fresheyeball> can you repost your version?
15:25 <Gurkenglas> c_wraith, that uses O(length xs) space
15:26 <c_wraith> Gurkenglas: nope. It uses O(n) space. It forces n more list elements than it returns.
15:26 zeroed joined
15:26 zeroed joined
15:26 davama joined
15:27 <Gurkenglas> c_wraith, it keeps track of all of xs even though it needs only the first n elements
15:27 <c_wraith> Gurkenglas: so assuming the producer uses O(1) space and the consumer uses O(1) space, the total memory use is O(n)
15:27 davama left
15:27 lambdaman joined
15:27 <fragamus> what's the most hipster cool parsing library available
15:27 <fresheyeball> I just want to see the version pleeeease
15:27 <Gurkenglas> When "rotate 3 [1..100]" is at (53, 50), 40 is still in memory
15:27 prophile joined
15:28 <c_wraith> Gurkenglas: oh, I guess cycle does keep the full thing around.
15:28 <erisco> > (partitions &&& rotations) [1,2,3]
15:29 <lambdabot> ([([],[1,2,3]),([1],[2,3]),([1,2],[3]),([1,2,3],[])],[[1,2,3],[2,3,1],[3,1,2...
15:29 <erisco> well it is all better now :)
15:29 <c_wraith> :t liftA2 (++) (drop n) (take n)
15:29 <lambdabot> error:
15:29 <lambdabot> • Couldn't match expected type ‘Int’ with actual type ‘Expr’
15:29 <lambdabot> • In the first argument of ‘drop’, namely ‘n’
15:29 <c_wraith> hah
15:29 <c_wraith> :t \n -> liftA2 (++) (drop n) (take n)
15:29 <lambdabot> Int -> [a] -> [a]
15:29 <Gurkenglas> Still O(n)
15:29 <Gurkenglas> *length xs
15:29 <peddie> has anyone here used SBV to prove properties about floating-point programs? I've just got started and am curious what kind of performance I should expect. I managed to run about 20 lines of code overnight last night
15:30 <c_wraith> yeah, you'd have to force the entirety of the taken list in order to let go of the reference to xs
15:30 osa1 joined
15:30 osa1 joined
15:30 <erisco> peddie, I am using it for other purposes and I think it is much more to do with the solver than SBV
15:30 seanpars1 joined
15:31 <peddie> erisco: interesting, thanks -- I'm using Z3. do you happen to know whether there is a better solver for the FP theories?
15:31 <erisco> if you're solving boat loads of problems then maybe SBV is a bottleneck for you
15:31 <erisco> but in my case I send tough problems at the solver and it takes a while
15:31 <peddie> erisco: how long is "a while?"
15:31 <dolio> Do any SMT solvers actually know about floating point, or do people just tell them to assume they're real numbers, even though that's wrong?
15:31 <peddie> dolio: you can go either way
15:32 <peddie> there are theories for IEEE floating-point numbers and for algebraic reals
15:32 <erisco> depends what I throw at it, but worse has been a couple minutes, which in my application counts as far too long
15:32 RegEchse joined
15:32 <erisco> I don't know which has the best FP theory support, sorry
15:32 alx741 joined
15:32 gugah joined
15:32 <peddie> erisco: got it, thanks. I realize I'm asking it to prove stuff about 64-bit doubles, so the search space is obviously massive. I'm just not sure how effective the FP theory is at reducing it
15:33 <Gurkenglas> :t \n xs -> let (t, d) = splitAt n xs in d ++ t -- c_wraith
15:33 <lambdabot> Int -> [a] -> [a]
15:34 <peddie> erisco: mind if I ask what your application is?
15:34 <erisco> as you might expect, my experience is if you do simple things then it tends to be alright
15:34 <c_wraith> Gurkenglas: it's the same thing as forcing the taken portion. With one less traversal of xs, but the memory use is the same.
15:34 <erisco> but if you start mixing and nesting quantifiers, for example, it becomes really unhappy
15:34 <peddie> erisco: yeah, I ran some simpler things which took anywhere from about 1 second to 10 minutes. haven't added any quantifiers yet.
15:35 <erisco> or if you start using quantifiers on array indicies which I had to abandon entirely
15:35 HoierM joined
15:36 <erisco> peddie, I am constructing puzzles. I am using it to find solutions of a puzzle and also to find constraints to add to a puzzle to limit the number of solutions
15:36 <erisco> I had to stop asking it the latter because it was too slow. I wrote a custom solver instead which is significantly faster
15:36 <peddie> what kind of puzzles?
15:36 <shapr> ooh, sgt puzzles?
15:37 <erisco> and now it is too slow for finding solutions of puzzles of 8x8, so I will have to write my own solver for that as well =\
15:37 <peddie> haha, OK
15:37 <erisco> after so long fiddling with it lol
15:37 newhoggy joined
15:37 freechips joined
15:38 <peddie> I guess we know it is NP-hard, after all -- we shouldn't expect it to be fast on problems of significant size :)
15:38 pie_ joined
15:38 <peddie> maybe I will have to give up on it
15:38 <pie_> hey. you guys have anything good to listen to while half-occupied?
15:38 <MarcelineVQ> what a neat little puzzle collection
15:38 <erisco> well, the problem is that I have to make my problem harder when I map it to what the solver understands
15:39 <pie_> MarcelineVQ, puzzles?
15:39 <pie_> :D
15:39 <MarcelineVQ> yeah, looks like a fun target for ML learning
15:40 <peddie> erisco: if `prove` is this slow, I can't imagine how slow `optimize` would be
15:40 <erisco> not necessarily harder in a complexity sense. I am not sure about that. but certainly the number of variables and size of expression explodes
15:40 hucksy joined
15:40 ertes joined
15:41 <MarcelineVQ> pie_: oh I meant the '<shapr> ooh, sgt puzzles?'
15:41 <shapr> yeah, I like sgt puzzles
15:41 <peddie> erisco: that's what kills you in an NP-hard problem :)
15:41 oleo joined
15:42 baldrick joined
15:42 <pie_> MarcelineVQ, i know you were talking to someone else :P
15:43 mada joined
15:44 <erisco> peddie, a puzzle is an unsolved board and a list of patterns. An unsolved board is a finite grid with pieces in some cells. A pattern is a grid with possible pieces in its cells.
15:45 <erisco> peddie, the puzzle is solved when the board is complete and for each pattern there exists some sub-grid of the board which it matches
15:45 newhoggy joined
15:46 robatosan joined
15:46 wildlander joined
15:47 <fresheyeball> is there a right way to keep a haskell process from exiting?
15:47 <erisco> my method of construction should work for many kinds of puzzles
15:47 <fresheyeball> I am using `void getLine`
15:47 <fresheyeball> feels dirty
15:47 fotonzade joined
15:47 <erisco> first I find up to two solutions of the puzzle. if there is just one then I am done. if there are none then I screwed up the initial puzzle... heh
15:47 <jchia_1> Question about TypeFamilies. Is it possible to require that the type synonym inside a class have an instance of some other class? E.g.: http://lpaste.net/355108
15:48 <erisco> with two solutions I then find a new constraint (in this case a pattern) to add which satisfies one solution but not the other
15:48 <erisco> I then repeat this process until one solution remains
15:48 <lyxia> jchia_1: yes
15:48 <erisco> this just depends on the initial puzzle having at least one solution and for there to always be some constraint which can satisfy one solution but not another
15:49 <erisco> then it converges on one solution
15:49 <jchia_1> lyxia: How do I express it?
15:49 <erisco> ... also assuming there are finite solutions
15:49 <DrMentats> fresheyeball: you could either sleep in a loop or use an MVar
15:49 <lyxia> jchia_1: class (Ix (Tag s)) => Taggable s
15:49 bvad joined
15:49 <erisco> annoyingly ever since people started talking about infinity we have to keep qualifying our quantities :P
15:49 <lyxia> jchia_1: + a bunch of language extensions
15:50 <lyxia> the compiler will tell you
15:50 <erisco> the challenge is constructing interesting puzzles rather than just any puzzle
15:51 <shapr> How do you define interesting? That sounds like a difficult task.
15:51 <lyxia> jchia_1: http://hackage.haskell.org/package/persistent-2.7.0/docs/Database-Persist-Class.html#t:PersistEntity is a prime example of this
15:51 <jchia_1> lyxia: Thanks, it seems to work.
15:51 <erisco> so if you applied this to Sudoku you would start with an initial board and find two solutions. then you'd choose any cell on one solution which didn't match the same cell on the other
15:51 <erisco> then repeat this process until one solution remains
15:52 vwker joined
15:52 <jchia_1> lyxia: Putting Tag before Taggable seemed a bit counter-intuitive, so I didn't think to try that.
15:52 <erisco> but still the challenge of finding interesting puzzles and not just any puzzle
15:52 mmn80 joined
15:53 <fresheyeball> DrMentats: how would I use an MVar?
15:53 tomphp joined
15:53 <fresheyeball> I thought this would work `newMVar () >>= readMVar`
15:53 <fresheyeball> but it doesn't hold on
15:53 newhoggy joined
15:53 <lyxia> jchia_1: yeah it looks surprising at first
15:54 lambdama_ joined
15:54 <MitchellSalad> fresheyeball: you'd have to 'takeMVar' on some MVar that some other thread will eventually put to
15:54 <erisco> shapr, yes it is annoying :P
15:54 <MitchellSalad> like this: 'mv <- newEmptyMVar; <fork worker thread stuff>; takeMVar mv'
15:54 <erisco> from the outset I have the problem that I cannot just search the whole space to find interesting puzzles
15:55 tomphp joined
15:55 <erisco> so instead I devise some criteria for where I'd like the puzzle to head as I am constructing it
15:55 <DrMentats> fresheyeball: then either putMVar from the worker thread when you want to exit
15:55 <fresheyeball> Ok that worked, thanks!
15:55 <DrMentats> or never do it if you want it to run forever
15:56 <erisco> constraint forms that I'd like to add to the puzzle
15:56 <fresheyeball> I didn't know about emptyMVars (I never use them)
15:56 beerdrop joined
15:56 nello78 joined
15:56 <erisco> and as I am constructing I then devise a way to search through the possibilities in a way that closely matches what I am looking for
15:56 <nello78> ciao
15:56 <erisco> I may end up with an exact match or a close match. I cannot guarantee anything
15:56 lambdaman joined
15:56 <MitchellSalad> fresheyeball: an MVar is either empty or full; reads block on an empty MVar and writes block on a full MVar
15:57 msko joined
15:57 <erisco> so with a model of these criteria I can then consider generating criteria themselves
15:57 <nello78> !list
15:58 <erisco> shapr, this is one of my secret weapons for doing that directed search http://hackage.haskell.org/package/data-list-zigzag
15:58 Aruro joined
15:58 nello78 left
15:59 epsilonhalbe joined
15:59 Itkovian joined
15:59 justin2 joined
15:59 <erisco> another reason I need a custom solver is because it matters greatly as to what two solutions I find
15:59 <shapr> erisco: that's neat
16:00 <erisco> if the two solutions are too close together (which CVC4 likes to do, for example) then I cannot find any interesting constraints
16:00 revtintin joined
16:00 <erisco> because almost everything matches both solutions
16:00 <shapr> erisco: So now you want to write an article about directed puzzle finding and ZigZag for The Monad.Reader, right?
16:00 rkazak joined
16:00 <erisco> but I also cannot afford to search through the whole solution set
16:00 <erisco> haha
16:01 <shapr> erisco: please yes?
16:01 newhoggy joined
16:01 doomlord joined
16:01 <shapr> You know I'm the new editor, aka person who must regularly beg for articles, yeah?
16:01 <erisco> it'd be premature at this point because I am still working on it
16:01 <shapr> I'm hoping to publish in July
16:01 pandeiro joined
16:02 <erisco> I have settled ZigZag but orphaned from the way I am using it there isn't much to talk about
16:02 <jchia_1> Given a data type T that has Bounded & Enum instance, is there a way to obtain a KnownNat for the fromEnum (maxBound :: T) - fromEnum (minBound :: T)?
16:02 fenedor joined
16:02 <shapr> I wish I could bribe glguy into writing an article about which libraries to import in order to solve programming puzzles in the least amount of time, along with some selections from his Advent of Code 2016 solutions.
16:03 fotonzade joined
16:04 <jchia_1> E.g. if I have data Foo = Bar | Baz deriving (Bounded, Enum), I would like to get a KnownNat 1.
16:04 mekeor joined
16:05 <glguy> jchia_1: At best you can get a 'Maybe SomeNat'
16:06 saurabhnanda joined
16:06 argent0 joined
16:07 eacameron joined
16:07 Sonolin joined
16:08 newhoggy joined
16:10 <jchia_1> glguy: That sounds like just someNatVal (fromEnum maxBound - fromEnum minBound).
16:10 <glguy> right
16:10 bvad joined
16:11 tromp joined
16:11 ctag joined
16:12 Gloomy joined
16:12 <cocreature> if you ensure that it’s not negative fromJust should be safe
16:13 meandi_2 joined
16:14 tomphp joined
16:15 Apocalisp joined
16:16 beerdrop joined
16:16 newhoggy joined
16:16 <jchia_1> Is zero included as one of the natural numbers for the purpose of type literals?
16:17 <glguy> Yes, 0 is a natural number
16:17 <jchia_1> glguy, cocreature: thanks
16:18 acertain joined
16:18 sssilver_ joined
16:21 splanch joined
16:21 Monoide joined
16:22 <Gurkenglas> Anyone using intero on windows? I seem to be having a problem with phantom ^M path endings
16:23 ragepandemic joined
16:24 <Myrl-saki> Why did they create PVP when Semver is already there?
16:24 newhoggy joined
16:25 jmelesky joined
16:26 <glguy> I think because of lack of time travel and because pvp has Haskell specific rules
16:26 nscott76 joined
16:27 flatmap13 joined
16:27 latro`a joined
16:28 arw_ joined
16:28 <c_wraith> Myrl-saki, the time travel part is important. semver is only already there if you're going backwards in time.
16:29 <cocreature> those lazy haskellers just didn’t want to invent time travel
16:29 <ggVGc> lack of time travel is such a nuisiance in general
16:29 <MarcelineVQ> new in ghc 9...
16:29 <Myrl-saki> Time travel?
16:29 <Myrl-saki> ._.
16:30 <glguy> If we had time travel we might not even need versioning, just go back in time to the initial package release any time you found a bug and fix it
16:30 <c_wraith> Myrl-saki, in particular, semver was not already there. the pvp is older.
16:30 <ggVGc> glguy: how do you solve merges?
16:30 <ggVGc> what if we both go back to the same version and fix it
16:30 <ggVGc> how do we manage time branches
16:30 <ggVGc> we're gonna need time-git
16:30 <glguy> With git
16:30 <Myrl-saki> c_wraith: Oh
16:30 tomphp joined
16:31 <Myrl-saki> I'm stupid lmao
16:31 <rotaerk> git to the future
16:31 lordalveric joined
16:31 <glguy> Things start getting confusing when timelines are rebased
16:31 <ggVGc> there's a problem with git though
16:31 <ggVGc> it's not written in haskell
16:32 trolling joined
16:32 <glguy> You're worried too many people will use it?
16:32 Fendoer joined
16:32 <MarcelineVQ> supra-liminal-darcs
16:32 <ggVGc> glguy: how do we manage the access keys for commits to different branches of time?
16:32 tristanp_ joined
16:32 statusbot joined
16:32 crobbins_ joined
16:32 <c_wraith> rebasing timelines is how you get Back to the Future 2.
16:32 <c_wraith> you don't want that.
16:32 <ggVGc> have you guys seen the time-branching episode of Rick and morty?
16:32 sleffy joined
16:32 torstein joined
16:33 dh____ joined
16:33 srcerer_ joined
16:33 <MarcelineVQ> c_wraith: luckily a later commit reverted the rebase
16:33 oleo_ joined
16:33 je5finge` joined
16:33 Ch3ck__ joined
16:33 mikecaruso1 joined
16:33 mauke_ joined
16:34 joeytwiddle_ joined
16:34 <MarcelineVQ> mmm it wasn't really time branching though was it, it was multiverse-branching, it just involved a 'time crystal'
16:34 tharper_ joined
16:34 theelous3 joined
16:35 oleo_ joined
16:35 statusbot2 joined
16:36 kaeluka_ joined
16:36 frontend1oader joined
16:36 Morgawr_ joined
16:36 mmachenry joined
16:36 robatosan joined
16:36 omilu_ joined
16:36 toure_ joined
16:36 skeuchel_ joined
16:36 AustinIncognito joined
16:36 tmciver_ joined
16:36 gallais_ joined
16:36 MitchW_ joined
16:37 bus000_ joined
16:37 benkard joined
16:37 CaptainProton_ joined
16:38 dh joined
16:39 oleo_ joined
16:39 _cyril__ joined
16:39 Argue joined
16:39 aminb_ joined
16:40 carbolymer_ joined
16:40 MindlessDrone joined
16:40 newhoggy joined
16:40 dsantiag_ joined
16:40 <peddie> erisco: thanks for the description, that sounds cool :)
16:40 eacameron joined
16:41 montik joined
16:41 fugyk joined
16:41 lambdabot joined
16:42 Gabemo joined
16:42 statusbot joined
16:42 Laney joined
16:42 mimi_vx joined
16:42 SlashLife joined
16:42 Neo joined
16:42 prooftechnique joined
16:42 pikajude joined
16:42 bennofs joined
16:42 Chobbes joined
16:42 ofdm joined
16:42 paroxp joined
16:42 rodarmor joined
16:42 dgpratt joined
16:42 nicknovi1 joined
16:42 thi_ joined
16:43 dstockwell joined
16:43 Denthir joined
16:43 Nycatelos joined
16:43 fuziontech joined
16:43 mbrcknl joined
16:43 chriswk joined
16:43 sanjoyd joined
16:43 athan joined
16:43 cyberlard joined
16:43 xcin joined
16:43 urodna joined
16:44 wting joined
16:44 anderson joined
16:44 lexi-lambda joined
16:44 alveric1 joined
16:45 naudiz joined
16:46 ctag joined
16:47 Purlox joined
16:47 hsiktas joined
16:47 capicue joined
16:47 SuperTux88 joined
16:47 darjeeling_ joined
16:47 maarhart joined
16:47 ner0x652 joined
16:48 suzu joined
16:48 dario` joined
16:48 augur joined
16:48 lassulus joined
16:48 Aruro joined
16:48 mjo joined
16:48 mjo joined
16:48 beerdrop joined
16:48 asakeron joined
16:49 jluttine joined
16:49 twold joined
16:49 chlong joined
16:49 Lord_of_Life joined
16:49 gehmehgeh joined
16:49 parsnip joined
16:49 raid joined
16:50 leobloom joined
16:51 ckubrak joined
16:51 eliasr joined
16:51 mthek joined
16:51 spicydonuts joined
16:51 mbeidler joined
16:51 Raynes joined
16:51 <Gurkenglas> Pressing M-. using intero for emacs on Windows produces lines like "make-directory: Creating directory: Invalid argument, c:/Users/Gurkenglas/intero-demo^M" (where the ^M disappears when you copypaste the line - I reinserted it here.) What do?
16:51 runeks joined
16:52 edwardk joined
16:52 bytesighs joined
16:52 hughrawlinson joined
16:52 reptar_ joined
16:52 reem joined
16:57 systadmin joined
16:58 newhoggy joined
16:59 zero_byte joined
16:59 mohsen_ joined
17:00 sajith joined
17:01 <Gurkenglas> "<sg2002> That stack thing even pulls msys2 and puts it into AppData. That's like even worse than defiling your PC with Haskell..." <- Is that bad, and is that necessary?
17:01 drcode joined
17:02 r0000007 joined
17:03 plutoniix joined
17:04 plutoniix joined
17:04 homesitter joined
17:04 oleo__ joined
17:07 nshepperd joined
17:07 guillaum2 joined
17:07 {emptyset} joined
17:09 oherrala joined
17:09 cpup joined
17:10 codesoup joined
17:10 r0000007 joined
17:10 tomphp joined
17:11 mstruebing joined
17:13 ckubrak joined
17:13 newhoggy joined
17:14 quaestor joined
17:15 twanvl joined
17:16 skeet70 joined
17:16 oleo__ joined
17:17 dm3 joined
17:17 dddddd joined
17:18 <Gurkenglas> To all who search the logs about my emacs problem in the future, it seems to appear iff I'm currently working from a desktop file (ie a session that's previously been saved when closing it) and removing the line that I put in the .emacs config myself to enable that got rid of this.
17:19 connrs joined
17:19 newhoggy joined
17:19 NeverDie joined
17:20 zero_byte joined
17:24 whiteline joined
17:24 ragepandemic joined
17:25 newhoggy joined
17:26 ckubrak joined
17:26 rkazak joined
17:26 pungi-man joined
17:27 DocWinter joined
17:28 mathk joined
17:28 <paolino> mh ghc got confused by me redefining Any
17:29 <paolino> well, defining actually
17:30 robatosan joined
17:30 <paolino> I changed to another name and now it compiles, GHC.Prim.Any got precedence without name clashing error
17:31 anzuof joined
17:31 newhoggy joined
17:31 bollu joined
17:32 biglambda joined
17:32 <bollu> is there any intuition behind the naming of runState / execState / evalState?
17:32 <bollu> I tend to google all three and find the one I want
17:32 <bollu> is there some sort of naming convention / mnemonic I'm missing?
17:33 <MarcelineVQ> yes, reflected in the types
17:33 eacameron joined
17:33 shayan_ joined
17:34 <paolino> eval is forget the state, exec is forget the value
17:35 montik joined
17:35 beerdrop joined
17:36 <mathk> Hi, in the parallel library can someone explain the difference between `evalList` and `parList` ? One difference that I can see is that the number of Spark is twice the length of the list with `parList` will it is exact length of list for the other.
17:36 replay joined
17:37 dm3 joined
17:37 <cocreature> mathk: the source of parTraversable and evalTraversable (evalList and parList are just special cases of that) is probably the best explanation https://hackage.haskell.org/package/parallel-
17:38 <Gurkenglas> bollu, eval as in evaluate as in value, run as in unpack the newtype, exec as in execute as in shut up and do the work
17:38 <MarcelineVQ> mathk: parList has an implicit rparWith added to your strategy
17:38 anzuof joined
17:38 rperry joined
17:38 insitu joined
17:38 <MarcelineVQ> via parTraversable
17:39 Discovery joined
17:39 SegFaultAX joined
17:39 <shapr> Has anyone tried https://github.com/iostreamer-X/FuncShell ?
17:39 <MarcelineVQ> cocreature: oop beat me to it :>
17:39 tzh joined
17:39 <bollu> :t evalState
17:39 <lambdabot> State s a -> s -> a
17:39 <bollu> :r runState
17:39 <bollu> :t runState
17:39 <lambdabot> State s a -> s -> (a, s)
17:40 <bollu> :r execState
17:40 <bollu> :t execState
17:40 <lambdabot> State s a -> s -> s
17:40 <bollu> ehh, I find "exec" weird
17:40 <bollu> but I get your point I guess
17:41 <cocreature> “parallel” is one of those packages that I’ve know about for a long time but I’ve never had a reason to use it
17:41 gugah joined
17:41 <MarcelineVQ> async is so much more common for your uses?
17:41 <cocreature> yep
17:42 jao joined
17:42 migge1 joined
17:43 <mathk> MarcelineVQ, not really understanding the idea behind
17:44 <mathk> I am reading the book "https://www.safaribooksonline.com/library/view/parallel-and-concurrent/9781449335939/"
17:44 mavihs[m] joined
17:44 <mathk> "Parallel and Concurrent Programming in Haskell"
17:44 epsilonhalbe left
17:45 <MarcelineVQ> hmm, that's an odd place to find that, you can read it here without needing a sign in as well http://chimera.labs.oreilly.com/books/1230000000929/index.html
17:45 systemfault joined
17:45 <Gurkenglas> With emacs, 'C-c p R' as per https://github.com/cydparser/demo-emacs-haskell/blob/master/demo.org#jump-to-dependency-definitions produces 'projectile-regenerate-tags: codex: C:\Users\Gurkenglas\Vorlagen: getDirectoryContents:findFirstFile: permission denied (Zugriff verweigert)' in the minibuffer. What should I do?
17:47 <Gurkenglas> (No idea why it's looking for a Vorlagen folder there. There's no such folder there.)
17:47 newhoggy joined
17:48 EvilMachine joined
17:48 tec_ joined
17:48 gawen joined
17:49 carlomagno joined
17:50 acarrico joined
17:51 <EvilMachine> Hi. I’m wondering: How does GHCi load modules on the fly or how does the RTS load dynamic modules/libraries? There is a common pattern in software of modular software and dynamic libraries. It has been suggested to me that this goes against the ideas behind Haskell and that I shouldn’t do it. (E.g. because type safety of modules unknown at compile time can obviously not be checked, or something.) So how is that patt
17:51 <EvilMachine> ern meant to be used, or what does one want instead when believing one wants such a pattern?
17:51 Itkovian joined
17:51 mr_sm1th joined
17:51 mikecaruso joined
17:52 <EvilMachine> (And I mean specifically when the main software only knows (in Java terms) Interfaces, and the modules provide (again in Java terms) Implementations.)
17:52 mavihs[m] left
17:54 JeanCarloMachado joined
17:54 Wizek_ joined
17:56 tcsavage joined
17:58 newhoggy joined
17:58 gehmehgeh joined
17:58 bvad joined
17:59 bollu joined
18:01 IanKelling joined
18:02 {emptyset} joined
18:04 jbgi joined
18:05 unyu joined
18:05 newhoggy joined
18:06 chaosmasttter joined
18:07 beanbagu1 joined
18:07 esph joined
18:07 eklavya joined
18:07 StoneToad joined
18:07 doomlord joined
18:07 plutoniix joined
18:07 jelleke joined
18:07 phyrex1an joined
18:08 yrid joined
18:08 xfix joined
18:09 jer1 joined
18:09 Fenedor joined
18:09 Big_G joined
18:09 c0dehero joined
18:09 raynold joined
18:09 plutoniix joined
18:10 ChaiTRex joined
18:10 jluttine joined
18:12 tromp joined
18:12 bennofs joined
18:14 eklavya joined
18:15 ubsan_ joined
18:15 jao joined
18:16 Morgawr joined
18:17 tec_ left
18:17 iskander joined
18:18 jbgi joined
18:18 plutoniix joined
18:18 newhoggy joined
18:19 iskander left
18:19 IanKelling joined
18:19 mac10688 joined
18:19 hexfive joined
18:20 JeanCarloMachado joined
18:21 argent0 joined
18:22 Itkovian joined
18:23 ckubrak joined
18:23 cpup joined
18:23 coltfred joined
18:23 Destol joined
18:23 jship joined
18:23 cyborg-one joined
18:24 ninjazoete joined
18:25 kiltzman joined
18:25 plutoniix joined
18:25 ragepandemic joined
18:26 pmade_ joined
18:27 <rotaerk> hmm... is it normal when parsing to have to express something as (a <* c) <|> (b <* c) instead of (a <|> b) <* c
18:27 newhoggy joined
18:27 <johnw> depends on which library you're using, and the way that 'a' is failing
18:28 <johnw> or wait, maybe not on 'a'...
18:28 <johnw> I'd expect that to work
18:28 bshelden joined
18:28 kamyar joined
18:28 leah2 joined
18:29 <rotaerk> well, the string I'm parsing might have substrings that are also valid a's, but I want it to consume all the way up to the c
18:29 Hamlet joined
18:29 robatosan joined
18:29 <Hamlet> Need help with this script / program ..
18:29 <lpaste> Hamlet revised “Find largest prime factor of 600851475143”: “Find largest prime factor of 600851475143” at http://lpaste.net/354950
18:30 pmade_ joined
18:31 Glooomy joined
18:31 <acertain> is there some way to get a free monad over a mtl-style typeclass?
18:31 <acertain> without writing a GADT
18:31 <kuribas> :t ($>)
18:31 <lambdabot> error:
18:31 <lambdabot> • Variable not in scope: $>
18:31 <lambdabot> • Perhaps you meant one of these:
18:31 <kuribas> :t (<$)
18:31 <lambdabot> Functor f => a -> f b -> f a
18:32 <mauke> Hamlet: your code is misnested
18:33 <rotaerk> if I do (a <|> b) <* c, instead of consuming the a up to the c, it will consume the valid substring that matches a, and then fail because it's not immediately followed by the c
18:33 <mauke> 'myGivenNumber' (which you need on the outside) is a variable that only exists on the inside
18:33 conal joined
18:33 <jship> @Hamlet This is a scoping problem. Try making myGivenNumber part of the 'where' too and then it will be accessible in largestPrimeFactor
18:33 <lambdabot> Unknown command, try @list
18:34 plutoniix joined
18:34 <Hamlet> I don't understand
18:34 <mauke> Hamlet: you can use 'let' for both myGivenNumber/largestPrimeFactor, or 'where' for both, or 'let' for largestPrimeFactor and 'where' for myGivenNumber
18:34 <mauke> any of those will work
18:34 <mauke> you've picked the one combination that makes no sense
18:34 <mauke> a 'where' clause attaches to a declaration, not an expression
18:34 Aruro joined
18:35 <mauke> i.e. 'largestPrimeFactor' scopes over the body of 'main'
18:35 <mauke> but 'myGivenNumber' only exists within 'main'
18:35 <Hamlet> can you fix it?
18:35 <mauke> yes
18:36 <mauke> and so can you, because I told you how
18:36 <lyxia> rotaerk: the behavior of (<|>) varies a lot depending on the parser
18:36 <Hamlet> how?
18:36 <mauke> Hamlet: you can use 'let' for both myGivenNumber/largestPrimeFactor, or 'where' for both, or 'let' for largestPrimeFactor and 'where' for myGivenNumber
18:37 <mauke> any of those will work
18:37 plutoniix joined
18:38 xslr joined
18:38 newhoggy joined
18:39 <acertain> is there TH somewhere to make a functor for use with free from a mtl-style typeclass?
18:39 <johnw> acertain: can you be a bit more specific?
18:39 tobiasBora joined
18:39 nomotif joined
18:40 nomicflux joined
18:40 <rotaerk> lyxia, ah
18:40 plutoniix joined
18:41 vikaton joined
18:42 Arizona6882 joined
18:43 <jle`> someone unleased a markov bot of haskell buzzwords onto #haskell again :)
18:43 flatmap13 joined
18:44 newhoggy joined
18:45 plutoniix joined
18:46 beanbagu1 joined
18:46 <acertain> actually i guess i just want like MonadReader => `data MonadReaderGADT r m a where Ask :: MonadReaderGADT r m r; Local :: (r -> r) -> MonadReaderGADT r m a -> MonadReaderGADT r m a; Reader :: (r -> a) -> MonadReaderGADT r m a`
18:47 <acertain> uh
18:47 texasmynsted joined
18:47 <acertain> also `Lift :: m a -> MonadReaderGADT r m a`
18:47 <johnw> can you move reader constraint into the constructor types?
18:47 romank joined
18:47 <johnw> that would make them only "evaluatable" in a MonadReader context
18:47 <acertain> huh?
18:47 <johnw> without having to construct them in such a context
18:47 iAmerikan joined
18:47 <johnw> data Foo a where Foo :: MonadReader r b => a -> Int
18:48 <acertain> no i need to inspect the GADT
18:48 <johnw> inspection would incur the constraint
18:48 plutoniix joined
18:48 <acertain> like pattern match on it
18:48 <johnw> why wouldn't you be able to?
18:48 <johnw> note: I use this pattern all the time, so maybe I haven't understood your query
18:49 rkazak joined
18:50 plutoniix joined
18:50 <acertain> i want to be e.g. foo Ask = bar; foo (Local f n) = baz
18:50 newhoggy joined
18:50 <johnw> why wouldn't that work?
18:50 <acertain> i could final-encode that, but i'd rather not
18:50 <johnw> what does final encoding have to do with this?
18:51 <acertain> i want to generate the corresponding initial encoding GADT from a final encoding typeclass
18:51 plutoniix joined
18:51 <acertain> basically
18:51 chaosmasttter joined
18:52 <acertain> ignoring laws
18:52 Fairy joined
18:52 <acertain> i just don't want to write the GADT by hand
18:52 kaimi1 joined
18:52 <johnw> ah
18:52 <johnw> I see
18:52 <johnw> you want reify a Monad* interface
18:53 <johnw> usually, you just write an instance to do this
18:53 <mathk> So when do I need to use evalList vs. parList ?
18:53 godel joined
18:53 <johnw> instance MonadReader r MonadReaderADT where ask = Ask; local = Local, etc.
18:53 sleffy joined
18:53 <johnw> then, take your MonadReader term, evaluate it to a MonadReaderADT value, and there you go
18:53 <acertain> sure, i just want to generate MonadReaderADT with TH
18:54 <johnw> yes, that should be straightforward to do
18:54 <johnw> I've written TH code to do the opposite, btw
18:54 <johnw> it would be a nice addition
18:54 <johnw> http://hackage.haskell.org/package/recursors
18:54 <johnw> that's goes from Initial -> Final using TH
18:54 <johnw> I'd _love_ a pull request to go from Final -> Initial :)
18:54 Hunter1 joined
18:56 plutoniix joined
18:56 newhoggy joined
18:58 plutoniix joined
18:59 fosskers joined
18:59 iAmerikan joined
18:59 gehmehgeh joined
19:00 leat joined
19:00 <fosskers> I'm having an attoparsec issue
19:00 sleffy_ joined
19:01 tomphp joined
19:01 Hamlet left
19:01 sleffy__ joined
19:02 <fosskers> I have a byte which denotes the number of bytes to follow it belonging to the same "group"
19:02 <fosskers> Parsing that byte and then passing it to Attoparsec's `take` gives us back the full `ByteString` of the bytes that followed
19:02 Itkovian joined
19:03 <fosskers> Except now I'd like to parse _that_ ByteString. The things inside the ByteString all use the same parser, but can each be of different length
19:04 conal joined
19:04 newhoggy joined
19:04 <fosskers> Previously I was ignoring the length byte, and just doing `many1 foo`, except that `foo` is generic enough in behaviour that it's eating the rest of the input
19:06 <fosskers> So I'm trying to reconsile either writing the parser I have now "better", or attempting some sort of "nested parsing" after heeding the length byte and using `take`. Any thoughts?
19:06 plutoniix joined
19:08 <fosskers> I don't think there's any way I can ignore this length byte anymore
19:09 _sg joined
19:09 <fosskers> `many1` will descend into gluttony unless I cap the amount of input it's allowed to look at
19:09 plutoniix joined
19:09 <fosskers> `take` seems like a good candidate, but then I'm confused about how'd I apply another layer of parsing to a `Parser ByteString` result
19:09 newhoggy joined
19:10 Hunter1 joined
19:10 ragepandemic joined
19:10 pie_ joined
19:11 biglambda joined
19:11 dm3 joined
19:12 romank joined
19:12 binaryplease joined
19:13 insitu joined
19:13 plutoniix joined
19:15 darjeeling_ joined
19:16 soniku joined
19:17 <lyxia> attoparsec doesn't have any way to "embed" a subparser on a bounded portion of input
19:17 newhoggy joined
19:18 <lyxia> just use parse or parseOnly
19:18 iAmerikan joined
19:18 modal joined
19:19 Fairy joined
19:20 <lyxia> I wonder how easy it would be to do something like that in a "neater" way
19:20 yqt joined
19:21 Boomerang joined
19:22 oish joined
19:23 carlomagno joined
19:23 newhoggy joined
19:24 IanKelling joined
19:25 robatosan joined
19:26 plutoniix joined
19:26 robotroll joined
19:27 fotonzade joined
19:28 acarrico joined
19:29 Velpoman joined
19:29 newhoggy joined
19:31 sigmundv_ joined
19:33 eschnett joined
19:34 richi235 joined
19:35 rkazak joined
19:35 <sm> I think megaparsec just added support for this
19:35 dm3 joined
19:35 Zemyla joined
19:36 <Gurkenglas> What's the most likely reason for and way to fix this? http://lpaste.net/5498937239993843712
19:36 <Gurkenglas> cloning exference and running stack build used to work, I think.
19:37 Itkovian joined
19:37 insitu joined
19:38 meoblast001 joined
19:38 zcourts joined
19:38 <sm> Gurkenglas: cabal file specifying a version of a package that isn't in the stackage snapshot you're using
19:38 <sm> possible quick fix: specify that version under extra-deps in stack.yaml
19:38 newhoggy joined
19:38 <rblaze> Gurkenglas which resolver version do you have in stack.yaml?
19:39 <Gurkenglas> rblaze, "lts-5.18". sm, 5.2 and 0.3.9 or 5.4.2 and 0.3.14?
19:39 <sm> better fix: update your cabal dependencies to use what's in the stackage snapshot you're specifying
19:39 plutoniix joined
19:40 <rblaze> Gurkenglas oh. the current one is 8.12
19:40 xcmw joined
19:40 <Gurkenglas> I suppose it's wise to get it running on the old versions before upgrading to new ones, rblaze, I haven't touched exference in a while
19:40 <sm> agreed
19:41 <hexagoxel> Gurkenglas: it seems to be caused by one of the last commits, most likely the one that changed the constraints.
19:41 <hexagoxel> (and sorry for not checking the stack build before releasing..)
19:41 <sm> so the problem is opposite to what I said (hard to read those errors): https://www.stackage.org/lts-5.18 has bifunctor 5.2, your cabal deps probably require a newer version
19:42 <rblaze> if exference requires bifunctors 5.4, and lts-5.12 only have 5.2, you are out of luck. Forcing other version will force rebuild of many snapshot packages.
19:42 plutoniix joined
19:42 <hexagoxel> Gurkenglas: e.g. HEAD~3 does not show this problem.
19:43 <Gurkenglas> What command is that to clone HEAD~3 instead of HEAD?
19:43 <sm> you could also try stack init/stack solver to get a stack.yaml suitable for HEAD
19:44 newhoggy joined
19:45 beerdrop joined
19:46 <hexagoxel> Gurkenglas: i have fixed the bounds in the .cabal; is pushed to HEAD
19:46 <hexagoxel> eh, s/HEAD/master/ i suppose.
19:47 beanbagu1 joined
19:47 <sm> nice
19:48 plutoniix joined
19:48 <hexagoxel> and true, maybe i should update the lts as well, although i see much less need for a mostly-only-executable package.
19:49 iAmerikan joined
19:49 lorena18 joined
19:50 <Tuplanolla> Today's xkcd did not need many changes to fit this channel perfectly: http://users.jyu.fi/~sapekiis/tmp/here-to-fp.png
19:50 newhoggy joined
19:51 zdorovo joined
19:51 <* ski> grins
19:52 <hexagoxel> Tuplanolla: Corepresentable,.. haha :)
19:53 ckubrak joined
19:54 robatosan joined
19:54 ubsan_ joined
19:56 <tfc[m]> lol
19:56 newhoggy joined
19:56 richi235 joined
19:57 soLucien joined
19:59 modal joined
20:00 <fosskers> Alright, I'll try a nested use of `parseOnly`
20:01 plutoniix joined
20:01 insitu joined
20:02 insitu joined
20:02 <Profpatsch> intersperse/intercalate in Foldable?
20:02 kamyar joined
20:03 plutoniix joined
20:03 <kamyar> Hello fellows
20:03 carlomagno joined
20:03 <kamyar> What is !ByteString? What is ! at first char?
20:03 <Profpatsch> kamyar: Strictness annotation
20:03 <Profpatsch> Will be evaluated to WHNF (I think?)
20:04 <kamyar> Profpatsch: thnx!
20:04 <Profpatsch> kamyar: See BangPatterns
20:05 Wizek_ joined
20:05 newhoggy joined
20:05 anuxivm joined
20:06 <sm> hexagoxel: one reason to keep the recommended lts fairly current is people are more likely to have it or something close already built
20:06 <Profpatsch> Hm, is there something like intercalate for Foldable/Traversable?
20:06 Itkovian joined
20:06 <Gurkenglas> Can intero jump to use sites of a definition too?
20:07 <Profpatsch> Oh, it probably doesn’t make much sense for e.g. Trees
20:07 <sm> (saving build time and disk space)
20:09 plutoniix joined
20:10 plutoniix joined
20:11 cdg joined
20:12 <hexagoxel> ah, true.
20:12 <Gurkenglas> :t over (partsOf traverse) . intersperse -- extremely law-breaking. Will stretch one half of the data and drop the rest. Why would you want this?
20:12 <lambdabot> Traversable t => b -> t b -> t b
20:14 <Gurkenglas> :t partsOf traverse %~ sort -- Who needs all those fancy innovative newtypes to sort any traversable, reddit? This one isn't even illegal.
20:14 <lambdabot> (Ord b, Traversable t) => t b -> t b
20:15 <johnw> I like "extremely law-breaking"
20:15 <johnw> I try to prove my theorems with extreme prejudice
20:16 samp joined
20:16 <hexagoxel> graphviz question: can anyone tell me if i am supposed to turn on OverloadedStrings? the examples in the haddocks seem to suggest it, but the ambiguities I get with it contradict.
20:17 <Twey> What's the reasoning behind the weird build-depends: base<=666 constraints I see around Hackage these days? ( https://www.google.co.uk/search?q=site:hackage.haskell.org+base+666 )
20:17 rameerez joined
20:18 soniku joined
20:18 sdrodge joined
20:18 plutoniix joined
20:19 <jle`> > over (partsOf traverse) sort (M.fromList (zip [1..] "hello"))
20:19 <lambdabot> fromList [(1,'e'),(2,'h'),(3,'l'),(4,'l'),(5,'o')]
20:19 <hexagoxel> Twey: i'd assume it to be a humorous protest against the call for upper bounds on dependencies.
20:20 sssilver joined
20:20 <jle`> hexagoxel: overloaded strings will often get ambiguous type errors during normal usage
20:21 Khisanth joined
20:21 IndigoTiger joined
20:22 xcmw joined
20:23 plutoniix joined
20:23 <hexagoxel> jle`: the thing is that the copy-pasted examples do not to work, neither with nor without OverloadedStrings.
20:23 seanparsons joined
20:23 r0000007 joined
20:24 <hexagoxel> with the error suggesting to use/not use the extension, always the opposite of one currently does :D
20:24 <hexagoxel> (well, that is my interpretation of the errors)
20:25 plutoniix joined
20:25 <jle`> there...might have been a breaking change without an update to the examples, heh
20:26 doomlord joined
20:27 rkazak joined
20:27 <cocreature> the error created by enabling OverloadedStrings are usually fixed by adding a few type annotations
20:27 plutoniix joined
20:27 yrdz joined
20:29 <hexagoxel> right; the type annotations are rather annoying due to the inference-inhibiting properties of this class: http://hackage.haskell.org/package/graphviz-2999.18.1.2/docs/Data-GraphViz-Types-Monadic.html#t:NodeList
20:29 xcmw joined
20:29 <hexagoxel> i.e. no functional dep (and not possible with such instances)
20:29 paul0 joined
20:29 crave joined
20:29 iAmerikan joined
20:30 <jle`> what a typeclass lol
20:31 coot joined
20:31 <hexagoxel> the package does this a lot, i.e. use-typeclasses-for-function-overloading
20:31 <cocreature> someone payed attention in “shitty haskell api design 101”
20:31 <jle`> it looks like that particular typeclass only appeared from 18.0 onwards
20:32 <jle`> so maybe the examples were not updated to reflect that
20:32 btorf joined
20:32 <jle`> or were updated and not tested
20:32 <jle`> actually it only showed up 18.1 onwards
20:33 <jle`> which was less than a year ago
20:33 <btorf> hey! is there a convention for the name of `liftM2 (>>)`?
20:34 <btorf> maybe (<>>>) ? but this looks really ugly
20:34 Tomatosoup- joined
20:34 Tomatosoup- left
20:34 Tomatosoup- joined
20:34 <Gurkenglas> If you're using it often enough to give it a name, maybe you want monad transformers... can we see the code?
20:34 <cocreature> btorf: just use "liftM2 (>>)". I don’t think that’s a function that’s often used (I can’t recall ever having used it)
20:34 <jle`> i don't think there is one....it sounds pretty specialized
20:35 iAmerikan joined
20:36 <bartavelle> is there a name for "start" and "end" nodes in directed graph, where all paths starting from a node A must go through a node B, and all paths crossing node B are reachable from A N
20:36 <bartavelle> ?
20:36 <btorf> oh ok. I thought this would could be a common pattern
20:36 <btorf> thx
20:37 geekosaur joined
20:37 <jle`> for the composition of two applicatives, (*>) = liftA2 (*>)
20:37 <jle`> so this is actually something you can access using a newtype wrapper
20:39 <jle`> btorf: so if you wrap f (g a) in a newtype wrapper, you can get (*>) on it to be your liftA2 (*>)
20:40 nekomune joined
20:40 fotonzade joined
20:40 <btorf> what do you mean "I can get"?
20:41 seanparsons joined
20:42 hust921 joined
20:42 carlomagno joined
20:42 <jle`> btorf: if 'x' and 'y' are your f (g a)
20:43 <jle`> then `Compose x *> Compose y` is liftA2 (*>) x y
20:43 shayan_ joined
20:43 plutoniix joined
20:43 <jle`> so *> will "be" liftA2 (*>)
20:43 vydd joined
20:43 vydd joined
20:45 <jle`> > Compose (Just [1,2,3]) *> Compose (Just ['a'])
20:45 <lambdabot> Compose (Just "aaa")
20:45 <jle`> > Compose (Just [1,2,3]) *> Compose Nothing
20:45 <lambdabot> Compose Nothing
20:45 <jle`> > Compose (Just [1,2,3]) *> Compose (Just [])
20:45 <lambdabot> Compose (Just [])
20:45 biglambda joined
20:45 <jle`> this is useful if you want to use your thing for applicative-polymorphic functinos, like sequenceA or traverse
20:46 fakenerd joined
20:46 <jle`> or even do notation
20:47 beanbagu1 joined
20:48 jimmyrcom joined
20:48 plutoniix joined
20:49 xfix joined
20:50 bollu joined
20:50 shainer joined
20:52 Alessio joined
20:52 <btorf> wow, thanks
20:52 seanparsons joined
20:53 xfix joined
20:54 <Gurkenglas> How do you abort a computation in intero's repl? (How could I have found that out?)
20:54 shainer left
20:55 plutoniix joined
20:55 <jle`> btorf: no problem! monad transformers let you generalize this to Monadic functions (like bind, etc.) too, but Compose is enough for Applicative and Functor functions
20:55 robatosan joined
20:56 hiptobecubic joined
20:56 Aruro joined
20:57 rkazak joined
20:57 fizbin joined
20:57 xcmw joined
20:58 plutoniix joined
20:59 ertesx joined
20:59 ckubrak joined
21:00 plutoniix joined
21:01 oish joined
21:02 <mrus> How do you read the pipe character in something like [2 ^ x | x <- [1..5]], when you try to speak this as a sentence?
21:02 <johnw> "taken from"
21:02 <EvanR> speaking source code?
21:02 plutoniix joined
21:02 <EvanR> i wonder what C sounds like
21:02 <johnw> as in "the list of elements 2^x where x is taken from the list [1..5]"
21:02 <mrus> EvanR: lol
21:03 <geekosaur> yeh, I would say "where" or possibly "given"
21:03 <mrus> johnw: so the pipe would be "where"?
21:03 <johnw> yeah, I suppose so
21:03 <johnw> "such that"
21:03 <geekosaur> "2 to the x power where x taken from the range 1 to 5"
21:03 <johnw> { x : nat | x < 10 }
21:03 <johnw> reads similarly
21:03 <geekosaur> or "such that", yes
21:03 <EvanR> yeah set theory speak
21:04 <mrus> hm, makes sense. I just thought that there's a more... like.. sophisticated way to formulate that.
21:05 <geekosaur> the sophisticated ways are all written with mathy symbols >.>
21:05 r0000007 joined
21:05 plutoniix joined
21:05 <mrus> heh
21:06 sanitypassing joined
21:06 richi235 joined
21:06 <tdammers> [ f x | x <- xs ] -- "f applied to x for x from xs" or "f applied to x for x in xs"
21:07 patbecich joined
21:07 <tdammers> (the second one is actually Python's list comprehension syntax: [ f(x) for x in xs ])
21:08 <* seequ_> loves Python's comprehension syntax
21:09 <mrus> how about: "2 to the power of x such as x is derived from 1 to 5"?
21:12 <ChaiTRex> mrus: "Derived" seems to imply a bit more than taken directly. I'd say something more like "2 to the x given x from 1 to 5".
21:13 <EvanR> hmm
21:13 <mrus> I see
21:13 geekosaur joined
21:14 mmachenry joined
21:14 tromp joined
21:14 <EvanR> [ 2^x | x <- [1..5] ] "2, 4, 8, 16, 32"
21:14 mmachenry1 joined
21:15 <Myrl-saki> Great, now add a second list comprehension and try to English it. :D
21:15 <EvanR> "the first through fifth powers of 2"
21:15 <mrus> :-D
21:16 romank joined
21:16 <Myrl-saki> [ x + y | x <- [1..5], y <- [1..5]]
21:16 <rotaerk> do { x <- [1..5]; y <- [1..5]; return $ x + y }
21:17 <geekosaur> "," is "and"
21:17 <michi7x7> > [ x + y | x <- [1..5], y <- [1..5]]
21:17 <lambdabot> [2,3,4,5,6,3,4,5,6,7,4,5,6,7,8,5,6,7,8,9,6,7,8,9,10]
21:17 <rotaerk> is there anything you can express with comprehensions that you can't trivially convert to a do expression like that?
21:17 <michi7x7> I wonder if that sequence has a name
21:17 <Myrl-saki> Now that I think about it, monad comprehension is... pretty useless.
21:17 <Myrl-saki> rotaerk: Nope.
21:18 seanparsons joined
21:18 <mrus> so, appaently Haskell developers don't need to speak their code pretty often. :-)
21:18 <Myrl-saki> raatiniemi: for testing, you use `guard`
21:18 <jle`> rotaerk: there's parallel list comprehensions
21:18 <Myrl-saki> jle`: Which is still easy.
21:18 <Myrl-saki> jle`: (zipN)
21:18 <jle`> less trivial :o
21:18 <jle`> especially if N > 7
21:19 newhoggy joined
21:19 <Myrl-saki> jle`: true.
21:19 <jle`> that's more ad-hoc/arbitrary
21:19 m0d joined
21:20 <michi7x7> mrus: well, try speaking C. You would still explain what the code does and not what it looks like.
21:20 plutoniix joined
21:22 <Myrl-saki> michi7x7: "oh, and I don't know why this part works, but it does"?
21:23 <thang1> "yeah it only segfaults on tuesdays. Just don't run the program past 8pm on tuesday, other than that it works perfect"
21:23 <Myrl-saki> thang1: "other than that it works perfect" I love that line.
21:23 <Myrl-saki> "I mean, if you don't consider the fact that it's broken, then it works."
21:24 <michi7x7> Myrl-saki: you would say something "filter out all even numbers in a loop" and not "in a for loop that increments i from 0 to 10, remove all elements for which isEven returns true"
21:24 plutoniix joined
21:24 <michi7x7> that's what I meant
21:24 plutoniix joined
21:24 <thang1> michi7x7: Which I always found pretty funny. "Yeah, when you're explaining how your code works step by step in C? Just write that explanation down in Haskell and it'll compile, probably"
21:25 <ChaiTRex> @undo [ 2^x | x <- [1..5]]
21:25 <lambdabot> concatMap (\ x -> [2 ^ x]) [1 .. 5]
21:25 mr_sm1th joined
21:25 featherlessbiped joined
21:25 seanpars1 joined
21:25 <ChaiTRex> @undo [ 2^x | x <- [1..5], isEven x ]
21:25 <lambdabot> concatMap (\ x -> if isEven x then [2 ^ x] else []) [1 .. 5]
21:25 <Myrl-saki> Eh
21:26 <Myrl-saki> > (2^) <$> [1..5]
21:26 <lambdabot> [2,4,8,16,32]
21:26 <thang1> (2^) <$> filter isEven [1..5] -- Would this even work?
21:27 <Myrl-saki> Yes.
21:27 <Myrl-saki> It will.
21:27 <thang1> > (2^) <$> filter isEven [1..5] -- Would this even work?
21:27 <lambdabot> error:
21:27 <lambdabot> Variable not in scope: isEven :: Integer -> Bool
21:27 <hiptobecubic> Tada!
21:27 <thang1> ;-;
21:27 <* thang1> is betrayed
21:27 <Myrl-saki> @let isEven x = (x `mod` 2) == 0
21:27 <lambdabot> Defined.
21:27 <Myrl-saki> Wait...
21:27 <Myrl-saki> :t even
21:27 <lambdabot> Integral a => a -> Bool
21:27 <hiptobecubic> :)
21:27 <* Myrl-saki> facepalms
21:27 <thang1> lol
21:28 <thang1> > (2^) <$> filter even [1..5] -- This time with feeling
21:28 <lambdabot> [4,16]
21:28 <michi7x7> > even == isEven -- can Haskell deduce smth like that?
21:28 <lambdabot> error:
21:28 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘even’
21:28 <lambdabot> prevents the constraint ‘(Integral a0)’ from being solved.
21:28 <Myrl-saki> michi7x7: subHask can.
21:28 Destol joined
21:28 plutoniix joined
21:28 <thang1> pretty sure it wouldn't do anything because you have two functions that haven't been applyed to anything
21:29 sanitypassing joined
21:29 <Myrl-saki> Though, the resulting type will be `:: Integral a => a -> Bool`
21:29 <geekosaur> functions have no Eq instance
21:29 newhoggy joined
21:29 doomlord joined
21:29 <Myrl-saki> It just so happens that the result is always True.
21:29 <geekosaur> however there is
21:29 <jle`> thang1: well, it'd be an (==) instance for (Int -> Bool), so it technically typechecks
21:29 <geekosaur> @hackage universe
21:29 <lambdabot> http://hackage.haskell.org/package/universe
21:29 <Myrl-saki> @hackage subhask
21:29 <lambdabot> http://hackage.haskell.org/package/subhask
21:29 <Myrl-saki> ;)
21:29 <ChaiTRex> michi7x7: That's impossible in general (halting problem), and I think that's part of the reason no one's included an attempt to do it.
21:29 <rotaerk> do { you <- even `liftM` bro; ... }
21:29 <thang1> oooh cool
21:29 <jle`> michi7x7: (==) is not provided by haskell in general
21:30 <jle`> it's implemented by users
21:30 <Myrl-saki> ChaiTRex: In general, sure.
21:30 <Myrl-saki> ChaiTRex: But `even == isEven` is easily decideable.
21:30 <ChaiTRex> It would be nice to be able to examine the AST or whatever for functions programmatically, though.
21:30 <ChaiTRex> Oh, sure. That one is easy.
21:30 <michi7x7> jle`: yeah, implementing Eq. I just liked the Idea
21:30 <ij> I've a "executable program" section in my "program.cabal" file. I want to write tests, so I've to include all "other-modules" and "build-depends" again? Repeat the 80 lines again, that is?
21:31 <jle`> you probably can write an instance of Integral where even == isEven is possible
21:31 <lyxia> ij: put it in a library
21:31 <jle`> well
21:31 <Myrl-saki> ChaiTRex: Oh wait no.
21:31 <glguy> ij: No, you just depend on the same library that has all the logic in it
21:31 <jle`> it wouldn't be a very useful Eq instance
21:31 oish joined
21:31 <jle`> since it would have to normalize function representations
21:31 sellout- joined
21:31 <ij> lyxia, Do I google "cabal library"?
21:31 <jle`> hm, actually, Eq a => Eq (Int -> a) is definally doable
21:31 <jle`> you'd just have to iterate over all of the Ints
21:32 <glguy> ij: For example https://github.com/glguy/irc-core/blob/v2/glirc.cabal#L155-L161
21:32 <Myrl-saki> jle`: Yep, ubt not Integral a => a -> b
21:32 <jle`> which is the premise of the 'universe' package
21:32 plutoniix joined
21:32 gihoveg joined
21:32 <jle`> you could use tricks like simple-reflect to prove that the two functions were created using the same abstract syntax tree
21:32 <jle`> but that would give false negatives
21:32 <geekosaur> ij, it's a matter of refactoring your executable into a library providing the guts, an executable that wraps the library, and then tests can access and test the guts via the library
21:33 <jle`> unless you had a way to normalize representations
21:33 heurist` joined
21:33 <mrus> michi7x7: `int x = 2; for(int i = 0; i < 5; i++) printf("%i\n", x << i);`: "with x being 2 and i being 0, while i is smaller than 5, increment i and bitwise shift x by the value of i". Pretty easy to speak, actually.
21:33 sanitypa1 joined
21:33 <jle`> michi7x7: for example, would even be the same as some other implementation that returned the same thing, but in a different way?
21:33 <jle`> you'd have to somehow deduce that (== 0) . (`mod` 2) is the same as, say
21:33 <jle`> (== 0) . (`mod` 2) . (+ 2)
21:34 <Myrl-saki> Universe a => Universe [a]
21:34 <Myrl-saki> This... makes no sense.
21:34 sssilver joined
21:34 <geekosaur> I was thinking one that tests the bottom bit
21:34 <jle`> even if you has access to the abstract syntax tree, you'd still get false negatives if you just compared the tree
21:34 <geekosaur> bit ops vs. modulus (even though, inside the CPU, they're likely the same!)
21:34 <jle`> since it would return "not equal"
21:34 <michi7x7> jle`: well, this is pretty similar to program optimization, no?
21:35 <pikajude> Myrl-saki: i think it's the entire universe of a inside lists of progressively larger size
21:35 <jle`> for `((== 0) . (`mod` 2) . (+ 2)) == ((== 0) . (`mod` 2))`
21:35 <ChaiTRex> michi7x7: Yeah.
21:35 <michi7x7> but I agree, it's not doable to implement this in a sufficiently exact way
21:35 Achylles joined
21:35 <ChaiTRex> You can do it with Equivalent | NotEquivalent | NotSure
21:36 <Myrl-saki> ++
21:36 <MarcelineVQ> data IsEven = SoEven | SoNotEven | IDontEven
21:36 <ChaiTRex> Haha
21:36 <Myrl-saki> MarcelineVQ: ICantEven.
21:36 okuu joined
21:36 bigos_ joined
21:36 Heasummn joined
21:36 <jle`> compare :: Lattice a => a -> a -> Maybe Ordering
21:36 <michi7x7> ChaiTRex: What about ceil . fromIntergal == floor . fromIntegral
21:36 sleffy joined
21:37 <jle`> (==?) :: MaybeEq => a -> a -> Maybe Bool
21:37 <MarcelineVQ> what does MaybeEq carry?
21:37 unyu joined
21:38 <ChaiTRex> :t ceil
21:39 <lambdabot> error: Variable not in scope: ceil
21:39 <ChaiTRex> :t ceiling
21:39 <lambdabot> (Integral b, RealFrac a) => a -> b
21:39 fizbin joined
21:39 <ChaiTRex> michi7x7: That would depend on the type in the middle.
21:39 niteria_ joined
21:39 <ChaiTRex> michi7x7: Hmm, no it wouldn't.
21:40 <ChaiTRex> michi7x7: For badly-acting middle types, I guess.
21:40 <Myrl-saki> I wonder why Maybe's default Monoid instance isn't First though.
21:40 <jle`> for me, it's more useful
21:40 <jle`> since we have <|>
21:40 Anonymous0250 joined
21:41 <Myrl-saki> jle`: Ah, true.
21:41 <Myrl-saki> jle`: But we can define `forall m. Monoid m => Maybe m -> m`
21:41 <jle`> but i'll admit, "in theory", the First instance "should" be the default instance
21:41 <Myrl-saki> jle`: :D
21:41 <jle`> but from an ecosystem perspective
21:42 <jle`> `Semigroup m => Monoid m` is bae
21:42 <jle`> er, Monoid (Maybe m)
21:42 seagreen joined
21:42 <Myrl-saki> ++
21:42 biglambda joined
21:42 <EvanR> michi7x7: deciding extensional equality of programs isnt possible
21:43 <Myrl-saki> `instance Applicative f => Monad (Fix f)` ?
21:43 kamyar joined
21:44 <jle`> ill-kinded
21:44 <kamyar> Hello all!
21:44 <jle`> hi!
21:44 <Myrl-saki> jle`: Oh true.
21:44 darjeeling_ joined
21:45 <kamyar> I have a somewhat difficult question about WAI
21:45 MrTheseus joined
21:46 <ij> glguy, Does library get attached to each section — test-suite and executable?
21:46 plutoniix joined
21:46 <kamyar> I am writing a middleware for WAI
21:46 <kamyar> I am getting username out of a bearer token
21:46 <kamyar> I can get username within any WAI (Scotty) function via request
21:47 <michi7x7> EvanR: assuming no side-effects and a closed and countable domain, you could compare results of course. If the program compiles to equal bytecode you can assume equality and proving (not finding) inequality is easy. I think that's about it
21:47 <kamyar> but I prefer a more beautiful solution
21:47 <kamyar> for example a function returning username which can be used anywhere
21:47 al-damiri joined
21:47 <EvanR> michi7x7: a countable domain, like Integer ? no its not possible
21:47 <kamyar> same as request which pints to current request
21:48 msko joined
21:48 <EvanR> that was the result of the entscheidungs problem
21:48 plutoniix joined
21:48 <EvanR> and if the domain and range were finite, you still cant compare results because one or both programs may not terminate
21:49 <Eduard_Munteanu> kamyar, well, you don't use a middleware then. A middleware is just an Application -> Application, but it seems you could use a (Username -> Application) -> Application
21:49 <EvanR> and unequal bytecode doesnt mean extensionally unequal
21:49 <dxtr> Hmm
21:50 <dxtr> What's the inverse of X OR !Y?
21:50 <EvanR> !(X OR !Y) ?
21:50 <pikajude> isn't it !X OR Y
21:50 <Eduard_Munteanu> !X AND !!Y?
21:50 plutoniix joined
21:50 <Eduard_Munteanu> No.
21:50 mbw joined
21:50 Itkovian joined
21:51 <Eduard_Munteanu> Negation inverts inputs and swaps 'or' for 'and' and viceversa.
21:51 mmn80 joined
21:51 <jle`> !(X or !Y), which you can simply using de morgan's laws
21:51 <dxtr> That's true
21:51 <jle`> => !X and !!Y
21:51 <EvanR> "simply"
21:51 <jle`> simplify ;_;
21:51 rkazak joined
21:51 iAmerikan joined
21:51 Hunter1 joined
21:51 <EvanR> "sadly" de morgan doesnt work intuitionistically
21:52 <Eduard_Munteanu> Well, one of them doesn't work.
21:52 <kamyar> Eduard_Munteanu: what do u mean? I have to intercept requests anyway
21:52 cloudhead joined
21:52 seanparsons joined
21:52 hpd joined
21:52 <jle`> (Either X (Y -> Void)) -> Void
21:52 gihoveg left
21:52 <kamyar> Eduard_Munteanu: But at the same time I need username many times
21:53 MP2E joined
21:53 hiratara joined
21:53 e14 joined
21:53 <Myrl-saki> > many $ Just 1
21:53 <mbw> Hello. Earlier today I asked about where to ask a rather lengthy question and got recommended to create a gist and post it on Reddit. Now I did all the markup work and I'm trying to create the gist on https://gist.github.com/. However I am not able to paste anything from the clipboard. I saw that there are scripts for this, but I wonder how you are "supposed" to use this?
21:53 <lambdabot> mueval-core: Time limit exceeded
21:53 <kamyar> Eduard_Munteanu: Where can I hold username when extracted in my middleware so that I could access it from anywhere in scotty
21:53 <kamyar> ?
21:53 plutoniix joined
21:53 <Myrl-saki> Okay. I have to ask why. Lol.
21:53 <jle`> @djoinn Either a (b -> Void) -> Void
21:53 <lambdabot> -- f cannot be realized.
21:53 <Eduard_Munteanu> kamyar, I'm suggesting you should write a withUsername :: (Username -> Application) -> Application such that your WAI application is withUsername applicationGettingUsernamePassed
21:54 <Eduard_Munteanu> kamyar, in a parameter or Reader environment
21:54 exferenceBot joined
21:54 <michi7x7> EvanR: yeah, you're right
21:54 <Myrl-saki> jle`: Sounds impossible.
21:55 <Gurkenglas> Myrl-saki, it doesn't know that it isn't going to be Nothing until it's evaluated all of the list
21:55 carlomagno joined
21:55 <EvanR> michi7x7: what you can do, though, is restrict the kind of programming language under scrutiny
21:55 <Myrl-saki> Gurkenglas: I see.
21:55 Skye_ joined
21:56 <EvanR> i dont know how primitive it needs to get before you can decide equality though
21:56 <Myrl-saki> Gurkenglas: Where can I use some/many then?
21:56 <Eduard_Munteanu> mbw, you're supposed to pipe the relevant bits into the script
21:56 robatosan joined
21:56 <Eduard_Munteanu> mbw, e.g. pastebinit < file.txt
21:57 <Eduard_Munteanu> mbw, if pasting doesn't work, remember there are two clipboards: one is triggered by the "paste" GUI command, the other by middle-click
21:57 <Gurkenglas> Myrl-saki, the fixed points of many as applied to Just 2 are undefined and Just (repeat 2). I advocate that we should not be using the least fixed point as the documentation says, but the greatest lower bound of the maximal fixed points, ie as long as there's only one way to go towards more defined, take it
21:57 <glguy> mbw: If you can't paste into the text box on gist.github.com it might be time to restart your computer or use a different browser
21:57 <michi7x7> EvanR: Hmm, I guess floating-point makes it quite hard already. If it's about math, the guys at Wolfram are probably the experts
21:58 <mbw> Eduard_Munteanu: Ok I just thought it should somehow be possible from the site. I used cat / xclip, which usually works. And I can paste it just fine in the title window, for instance.
21:58 <mbw> Where it says file title plus extention.
21:58 k0001 joined
21:59 <Gurkenglas> In practice, you just promise Haskell that it's not undefined and it goes along with it. I've written this into Control.Alternative.Pointed and then manyLazy (Just 2) = Just (repeat 2) https://hackage.haskell.org/package/pointedalternative-
21:59 <Eduard_Munteanu> xclip sometimes picks the wrong clipboard
21:59 <Eduard_Munteanu> There are actually 3 of them.
21:59 <Myrl-saki> Gurkenglas: Ah.
21:59 <mbw> Yeah you have to invoke it via cat somefile.txt | xclip -selection "clipboard".
22:01 <Eduard_Munteanu> mbw, try opening the file in a GUI editor like gedit
22:01 <Myrl-saki> Eduard_Munteanu: mbw?
22:01 <Myrl-saki> might be worth trying?
22:01 <mbw> Like I said, I can paste in "Gist description" and "Filename including extension".
22:02 <Eduard_Munteanu> Hm.
22:02 <mbw> I don't think I am trying to paste from the wrong clipboard.
22:02 <Myrl-saki> Eduard_Munteanu: Oh wait. I'm stupid.
22:02 e14 joined
22:02 plutoniix joined
22:02 malakin joined
22:02 <Myrl-saki> I thought it was an acronym.
22:02 <Myrl-saki> Whoops.
22:02 <Gurkenglas> Of course, why not just use repeat? Maybe is not the only Alternative. For the prototype, I also lift instances through StateT s, where many makes more intuitive sense (the term originally comes from parser combinator libraries, which are pretty close to StateT String)
22:02 <Eduard_Munteanu> :)
22:02 <thang1> Eduard_Munteanu: that's why I merge all of my clipboards in linux :p
22:03 <Myrl-saki> Eduard_Munteanu: I blame you for not using colons like normal people. :D
22:03 <Eduard_Munteanu> Comma seems a bit more natural for addressing people.
22:04 <Myrl-saki> Eduard_Munteanu: Everyone else in IRC is a bot though.
22:04 <thang1> colon is default on my irc client. I usually have it changed to comma but every now and then I reset my irc config and that bit gets undone
22:04 seanparsons joined
22:04 <Eduard_Munteanu> I think I had it set manually too.
22:04 <Gurkenglas> > evalStateT (many $ do i <- StateT uncons; modify $ drop i) [1..] -- which leads to this, which must first go through the infinite list...
22:04 <monochrom> Best of both world --- use ;
22:04 plutoniix joined
22:04 <lambdabot> mueval-core: Time limit exceeded
22:04 <mbw> Depending on your irc client, it might make a difference. With irssi, in "<nick>: Bla bla bla", your own nick will get highlighted.
22:04 <rotaerk> hmm, I should change my default to exclamation mark
22:04 seanparsons joined
22:05 <Eduard_Munteanu> Good point, mr. compromise. :)
22:05 <monochrom> ;)
22:05 <mbw> Anyhow, noscript isn't at fault either. I'll just try to use one of those scripts.
22:05 malakin joined
22:05 <Myrl-saki> I disagree. If we'll make something different, it shoul be totally different.
22:06 iqubic joined
22:06 <Gurkenglas> > evalState (manyLazy $ do i <- StateT uncons; modify $ drop i) [1..] -- becoming this. (with bonus type-level justice gurantee)
22:06 <lambdabot> mueval-core: Time limit exceeded
22:06 <Gurkenglas> fail. wat
22:06 <Myrl-saki> Gurkenglas: lmao
22:06 <monochrom> Use @ but put it after, not before. "monochrom@ Hey that's an excellent idea!"
22:07 <mbw> Why not a lambda? Harder to type, too.
22:07 <Myrl-saki> lambda in Haskell should have been ,\
22:07 <mbw> That looks like lambda's crippled brother.
22:07 <iqubic> So I'm trying to write my own version of ExceptT. How does this look: http://termbin.com/gh84
22:07 <Myrl-saki> Look at how beautiful that is.
22:07 tomphp joined
22:07 <rotaerk> dangit, I tried changing my addressing suffix to >>=
22:08 <rotaerk> but hexchat ignores all but the first char
22:08 <iqubic> Note that all of that except for the type hole at the bottom type checks.
22:08 <monochrom> ah dang it, rotaerk.
22:08 <Gurkenglas> > evalState (manyLazy $ StateT uncons) [1..] -- Hm, this works. Whence divergence?
22:08 <jle`> iqubic: nice :)
22:08 <lambdabot> [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,...
22:08 plutoniix joined
22:08 <iqubic> So, anyone know if my implementation of ExceptT works?
22:08 <hexagoxel> there must be some unicode 1-char >>=
22:08 <iqubic> Is it correct?
22:09 <Myrl-saki> hexagoxel: There is if you consider user-defined unicode.
22:09 <reactormonk[m]> How do I add type annotation to a variable in a do block? For type inference.
22:09 <reactormonk[m]> When I add it directly to the left of the <-, it tells me something about scoped type variables.
22:09 sssilver_ joined
22:09 <jle`> reactormonk[m]: you can do (a :: Int) <- ..., if you turn on ScopedTypeVariables
22:09 <jle`> reactormonk[m]: yes, that's an extension
22:10 <reactormonk[m]> Does it do what I expect?
22:10 <Gurkenglas> > evalState (manyLazy $ do i <- StateT uncons; modify $ drop $ mod i 4; return i) [1..] -- Oh, of course. It originally ~doubled the amount of droppings each time :)
22:10 <lambdabot> [1,3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,...
22:10 <geekosaur> reactormonk[m], it used to be a separate extension but got rolled into ScopedTypeVariables extension
22:10 <Eduard_Munteanu> Yes.
22:10 jmcarthur joined
22:12 <iqubic> So no one is able to look at my implementation of ExceptT?
22:13 plutoniix joined
22:13 <jle`> iqubic: looks solid to me
22:13 <iqubic> Does it?
22:14 <jle`> yup
22:14 <jle`> next try Alternative
22:14 <iqubic> Why do I need to have Instance MonadTrans (ExecptT e) where... and not MonadTrans ExceptT?
22:15 <jle`> iqubic: what is the kind of MonadTrans
22:15 <Eduard_Munteanu> :k ExceptT
22:15 <lambdabot> * -> (* -> *) -> * -> *
22:15 <iqubic> :k MonadTrans
22:15 <lambdabot> ((* -> *) -> * -> *) -> Constraint
22:15 <mbw> Ok I managed the gist thing using the `gist` ruby script. However, the rendering looks way different (fortunately, better) than what I got from using pandoc. How do people usually test their markdown? I invoked pandoc like `pandoc -f markdown_github -t html thefile.md &> thefile.html`.
22:15 <jle`> the name of the typeclass should give you a hint
22:15 <jle`> something is a MonadTrans if it's a function from monad to monad
22:15 begriffs joined
22:15 plutoniix joined
22:16 <jle`> so if 't' is a MonadTrans, it takes a Monad ( * -> * ) and returns another one ( * -> * )
22:16 <iqubic> So do I need to use that e for anything?
22:16 <jle`> so if t is a MonadTrans, it has kind (* -> *) -> (* -> *)
22:16 <jle`> 'ExceptT e' has that kind
22:16 <iqubic> Right.
22:16 <jle`> 'ExcetT e :: (* -> *) -> (* -> *)'
22:16 <jle`> ExceptT does not
22:16 <jle`> ExceptT takes an error type, and a monad, and then returns a monad
22:17 <iqubic> So what do I do to fill in my type hole?
22:17 <jle`> your typed hole?
22:17 <jle`> follow the types
22:17 <Eduard_Munteanu> :t lift
22:17 <lambdabot> (Monad m, MonadTrans t) => m a -> t m a
22:17 <jle`> :)
22:17 <iqubic> DO I need to use the e at all?
22:17 <Eduard_Munteanu> Replace 't' with 'ExceptT e' and see.
22:18 <iqubic> I don't think I will need to.
22:18 <Eduard_Munteanu> Yeah.
22:18 <jle`> what do you mean by 'use the e', anyway?
22:18 <jle`> use any value of type 'e' ?
22:19 <iqubic> Do I need to use the variable e anywhere in my functions?
22:19 <jle`> the type variable?
22:19 <iqubic> Oh, wait I'm dumb
22:19 <iqubic> I see how to do this.
22:19 soniku joined
22:19 <jle`> you usually don't have to use type variables
22:19 <Eduard_Munteanu> lift should be really straightforward.
22:19 <jle`> note that you bind the type variable 'e' for the Functor, Applicative, and Monad instances
22:19 <iqubic> It was.
22:20 <jle`> and you never explicitly use the type variable in any of those implementations
22:20 <iqubic> lift c = ExceptT $ fmap Right c
22:20 <jle`> in fact it should be possible to never need to explicitly refer to bound type variables for the most part
22:20 butterthebuddha joined
22:21 godel joined
22:21 <iqubic> So what does alternative do?
22:21 <Eduard_Munteanu> Do you know MonadPlus?
22:21 <iqubic> I want to try writing alternative instances for my MaybeT and my ExceptT
22:21 <glguy> iqubic: Have you looked at the haddock for the typeclass yet?
22:21 <jle`> in general, it can do anything as long as it's monoidal
22:22 <iqubic> Eduard_Munteanu: What is MonadPlus?
22:22 LiaoTao_ joined
22:22 <jle`> but for ExceptT e, it has a specific "expected" behavior
22:22 <iqubic> glguy: I have not.
22:22 <glguy> OK, that's the right place to start
22:22 <Eduard_Munteanu> Something akin to Alternative, I was going to explain Alternative in terms of that.
22:22 <jle`> `x <|> y` for ExceptT should be a short-circuiting either-or
22:23 <jle`> so if x is Right, it'll return Right w/ whatever x is; otherwise it'll execute y
22:23 <thang1> Finally submitted my summer of code application!
22:23 <iqubic> jle`: I'm not ready for that.
22:23 <jle`> this isn't the only Alternative instance possible (from the laws of Alternative), but it's the one people expect
22:23 <jle`> iqubic: i think you are
22:23 <iqubic> I want to learn about MonadPlus first
22:23 <jle`> since it's easier than (>>=)
22:23 <jle`> MonadPlus is just Alternative
22:23 <jle`> with an uglier name
22:23 <jle`> and more laws
22:23 <iqubic> It is?
22:23 <jle`> yes, it has the same methods
22:23 <jle`> it's a historical accident
22:24 <iqubic> Alright, what do I need to implement Alternative?
22:24 <jle`> `x <|> y` should do x, and return the result if x is Right
22:24 <jle`> otherwise it'll do y and return the result of y
22:24 <iqubic> What is the header for Alternative (ExceptT e)
22:24 <thang1> Y'know, the more I hear about these historical accidents, the more I wish we would just fix some of this shit...
22:24 <jle`> Alternative is * -> *
22:24 <pikajude> Right x <|> _ = Right x, _ <|> y = y
22:24 <monochrom> need a time machine
22:24 <jle`> you might need a Monoid constraint on e
22:25 <iqubic> Why do I need a monoid constraint?
22:25 bsrm joined
22:25 <pikajude> good question
22:26 oisdk joined
22:27 ystael joined
22:27 <iqubic> @index (<|>)
22:27 <lambdabot> Control.Applicative
22:28 <iqubic> What is the header for Alternative. I know I need something of kind * -> * but what do I write?
22:29 <Eduard_Munteanu> :k Alternative
22:29 <lambdabot> (* -> *) -> Constraint
22:30 <iqubic> What does that mean?
22:30 <Eduard_Munteanu> Start with Alternative (ExceptT e m) and go from there.
22:30 roconnor joined
22:30 m0d joined
22:30 <Eduard_Munteanu> It will become apparent if you need other constraints.
22:31 <iqubic> What is empty supposed to return?
22:31 hiratara joined
22:31 <Eduard_Munteanu> Look at the laws. It gives you a value such that empty <|> x = x
22:31 splanch joined
22:31 <iqubic> Why is that god?
22:32 <iqubic> s/god/good/
22:32 <Eduard_Munteanu> Alternative is a monoidal structure in which 'empty' is the identity element.
22:33 <iqubic> But why is Alternative even any good?
22:33 <Eduard_Munteanu> iqubic, for one thing it can be used to represent Applicatives which can fail
22:34 <pikajude> it's good for parsers
22:34 <pikajude> also, if you have two Maybes and you want either of them, but not both, you can use foo <|> bar
22:34 <pikajude> stuff like that
22:35 <iqubic> Are Alternatives only used with Monad Transformers?
22:35 <Eduard_Munteanu> No.
22:35 conal joined
22:35 <Eduard_Munteanu> Maybe is an Alternative for example.
22:36 <Eduard_Munteanu> > Nothing <|> Just 3 <|> Just 5
22:36 <lambdabot> Just 3
22:36 <iqubic> Why is that Just 3?
22:36 <iqubic> What is that doing?
22:36 <Eduard_Munteanu> iqubic, it gives you the result of the first action that succeeds
22:37 <Eduard_Munteanu> (Nothing is failure)
22:37 <pikajude> someone decided that Alternative would be useful and that implementation is the one that fulfills the laws for Alternative
22:37 <pikajude> > optional Nothing
22:37 <lambdabot> Just Nothing
22:37 <pikajude> > optional (Just 3)
22:37 <lambdabot> Just (Just 3)
22:38 <pikajude> that's odd
22:38 <iqubic> What does optional do?
22:38 <iqubic> :t optional
22:38 <lambdabot> Alternative f => f a -> f (Maybe a)
22:38 <Eduard_Munteanu> > optional 3
22:38 <lambdabot> error:
22:38 <lambdabot> • Ambiguous type variables ‘f0’, ‘a0’ arising from a use of ‘show_M50343...
22:38 <lambdabot> prevents the constraint ‘(Show (f0 (Maybe a0)))’ from being solved.
22:38 <glguy> pikajude: why is it odd?
22:38 robatosan joined
22:38 <pikajude> glguy: i forgot what optional should do for Maybe
22:38 aarvar joined
22:38 <pikajude> i've only used it in parsers :)
22:38 <iqubic> > join $ optional $ Just 100
22:38 <Eduard_Munteanu> > Nothing <|> optional 3
22:38 <lambdabot> Just 100
22:38 <lambdabot> error:
22:38 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M386665625860...
22:38 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
22:38 <iqubic> > join $ optional $ Just 100
22:38 <lambdabot> Just 100
22:39 oisdk joined
22:39 <pikajude> join . optional doesn't really make any sense
22:39 <pikajude> i think it's always going to be id
22:40 Koterpillar joined
22:40 <glguy> > optional [3..5]
22:40 <lambdabot> [Just 3,Just 4,Just 5,Nothing]
22:41 <iqubic> Does empty need to take any parameters?
22:41 fizbin joined
22:41 <Eduard_Munteanu> :t empty
22:41 <lambdabot> Alternative f => f a
22:41 <iqubic> So, I'm at a loss here.
22:41 <glguy> what's confusing?
22:41 <pikajude> empty <|> x should be x
22:42 nomicflux joined
22:42 sleffy joined
22:42 <iqubic> I have this so far: empty = ExceptT $ return $ Left _
22:42 <iqubic> I don't know what to put in that type hole.
22:43 <pikajude> maybe that's why Eduard_Munteanu suggested a Monoid e
22:43 <pikajude> then you can put mempty in
22:43 <Eduard_Munteanu> Someone else did.
22:43 augur joined
22:43 <iqubic> But do I need the monoid constraint?
22:44 <Eduard_Munteanu> It's one way to get an 'e'.
22:44 tobiasBora joined
22:45 <iqubic> Yeah. Are there any other ways to get it?
22:45 <Eduard_Munteanu> Another is IsString e.
22:45 unyu joined
22:45 <iqubic> How does that work?
22:46 <Eduard_Munteanu> :t fromString
22:46 <lambdabot> IsString a => String -> a
22:46 <iqubic> Eduard_Munteanu: What would you do?
22:47 <Eduard_Munteanu> Monoid is probably better for now.
22:47 <Eduard_Munteanu> :t mempty
22:47 <lambdabot> Monoid a => a
22:47 yrdz joined
22:47 <Eduard_Munteanu> Also Error.
22:48 <iqubic> What is Error?
22:48 <Eduard_Munteanu> @src Error
22:48 <lambdabot> class Error a where
22:48 <lambdabot> noMsg :: a
22:48 <lambdabot> strMsg :: String -> a
22:48 <benzrf> huh
22:49 <iqubic> Do I need to use Error?
22:49 sz0 joined
22:49 <Eduard_Munteanu> No.
22:49 <Eduard_Munteanu> There are many possible instances.
22:49 <iqubic> I selected on that seems to work.
22:50 <iqubic> s/on/one/
22:50 <iqubic> Now how do I write <|> for ExceptT?
22:50 <glguy> The benefit of the Monoid choice over Error or IsString is that empty is actually able to be both the left and right identity of <|>
22:51 sleffy_ joined
22:51 <iqubic> Yeah.
22:51 <iqubic> Note I'm not writing this for Either, but for ExceptT
22:52 <NickHu> If I have lenses for a record type, how can I use those to create a value of that type without already having an existing default value (or something like that)?
22:52 <glguy> iqubic: That's fine. Give it a shot. If you get stuck you can put the code up on lpaste.net
22:52 <glguy> NickHu: No, not really
22:52 sleffy__ joined
22:53 zero_byte joined
22:53 <glguy> NickHu: If you do that you'll need to make sure you specially craft your lenses to be that lazy (which you'll need to be very careful about later to avoid leaking in normal use)
22:54 splanch joined
22:54 jmiven joined
22:54 <glguy> NickHu: If you're not worried about memory behavior you can generate those kinds of lenses with: http://hackage.haskell.org/package/lens-4.15.2/docs/Control-Lens-TH.html#v:generateLazyPatterns
22:55 <glguy> in that case that URL includes an example of how to do it
22:55 <iqubic> > Left 5 <|> Right 5
22:55 <lambdabot> error:
22:55 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M252048480198...
22:55 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
22:55 <iqubic> Why does that not work?
22:55 <Eduard_Munteanu> If you have control over the type, you should just construct a value with record syntax.
22:56 <Eduard_Munteanu> :t Left 5 <|> Right 5
22:56 <lambdabot> (Num a, Num a1, Control.Monad.Trans.Error.Error a1) => Either a1 a
22:57 e14 joined
22:57 <Eduard_Munteanu> > Left "err" <|> Right 5
22:57 <lambdabot> Right 5
22:57 <iqubic> Eduard_Munteanu: Why does that have the Error constraint?
22:58 <benzrf> :t (<|>)
22:58 <lambdabot> Alternative f => f a -> f a -> f a
22:58 <benzrf> huh
22:58 <benzrf> orphan instance?!
22:58 <Eduard_Munteanu> iqubic, because that's what they've chosen to use for Either's Alternative instance
22:59 butterthebuddha joined
23:00 newhoggy joined
23:01 <iqubic> http://termbin.com/6xai
23:01 <iqubic> What do I do from there?
23:01 mithrandeer joined
23:01 <glguy> You'll need to fill in the definitions in your Alternative instance
23:01 <Eduard_Munteanu> iqubic, haven't you already done empty?
23:01 <glguy> like you did in the other instances
23:02 mekeor joined
23:02 <iqubic> Eduard_Munteanu: See this instead http://termbin.com/1ate
23:03 oleo_ joined
23:03 <glguy> iqubic: thinking about what to do next is the whole exercise
23:03 duetosymmetry joined
23:04 <iqubic> What if both parts of <|> are Left?
23:04 <Eduard_Munteanu> iqubic, remember you're looking to handle failure
23:04 <Eduard_Munteanu> Then the whole thing fails.
23:04 <iqubic> I am?
23:05 AntiSpamMeta joined
23:05 <iqubic> How do I return failure as an ExceptT?
23:07 Taslem joined
23:07 <Eduard_Munteanu> Well, you might already have a failure, i.e. a Left inside m
23:08 <duetosymmetry> pl \ls -> any (== 0) [x+y | x<-ls, y<-ls]
23:08 <duetosymmetry> > pl \ls -> any (== 0) [x+y | x<-ls, y<-ls]
23:08 <lambdabot> <hint>:1:4: error: parse error on input ‘\’
23:08 dan_f joined
23:08 mbw joined
23:08 <Eduard_Munteanu> And you can also make further use of the Monoid and add up the errors.
23:09 oisdk_ joined
23:09 <iqubic> I can?
23:09 beanbagu1 joined
23:09 <iqubic> How can I do that?
23:09 <Eduard_Munteanu> Though it's most natural to drop leftmost failures.
23:10 <mbw> Alright, I posted my first reddit post ever on /r/haskell. However, it doesn't show up for me under new, so either I've managed to screw it up somehow, or it has to be confirmed by a moderator or something like that, since my account is new. The post can be found here: https://www.reddit.com/r/haskell/comments/68pc7a/equational_reasoning_with_multidimensional_arrays/ . Did I do it right?
23:10 <glguy> dropping the left-most failure stops empty from being the right identity
23:11 safe joined
23:11 <Eduard_Munteanu> Oh, right.
23:11 <duetosymmetry> > pl (\ls -> any (== 0) [x+y | x<-ls, y<-ls])
23:11 <lambdabot> error:
23:11 <lambdabot> • Variable not in scope: pl :: ([Integer] -> Bool) -> t
23:11 <lambdabot> • Perhaps you meant one of these:
23:11 <glguy> duetosymmetry: You can play with lambdabot privately with /msg lambdabot
23:11 <Eduard_Munteanu> @pl \ls -> any (== 0) [x+y | x<-ls, y<-ls]
23:11 <lambdabot> any (0 ==) . ap ((:) . (x +) . ((y | x) <-)) (return . (y <-))
23:11 <duetosymmetry> @glguy sorry for the spam, thx for the help
23:11 <lambdabot> Unknown command, try @list
23:11 pera joined
23:12 <glguy> and @pl doesn't work for list comphrehensions
23:12 soniku joined
23:12 <Eduard_Munteanu> @. pl undo \ls -> any (== 0) [x+y | x<-ls, y<-ls]
23:12 <lambdabot> any (0 ==) . ((=<<) =<< (. (flip flip [] . ((:) .) . (+))) . (>>=))
23:12 <Eduard_Munteanu> :)
23:12 crobbins_ joined
23:13 Welkin joined
23:13 <iqubic> What's the canonical implementation of <|> for ExceptT?
23:13 alveric1 joined
23:13 <glguy> iqubic: You can find it in the transformers package
23:13 <glguy> just click the Source link next to the instance
23:14 <Eduard_Munteanu> @src Alternative ExceptT
23:14 <lambdabot> Source not found. Abort, Retry, Panic?
23:14 sanitypassing joined
23:15 <iqubic> glguy: I want to try writting it myself. I just want to know what it should do.
23:15 newhoggy joined
23:16 <Eduard_Munteanu> iqubic, you have that Monoid constraint, go ahead and use it
23:16 mmachenry joined
23:17 <iqubic> How will that help me?
23:17 takle joined
23:17 <Eduard_Munteanu> iqubic, it matters for handling Lefts
23:18 <iqubic> How do I return an m (Either e a) that represents failure?
23:18 <Eduard_Munteanu> return (Left ...)
23:19 sgronblo joined
23:19 <iqubic> So m (Left e) is failure?
23:19 hamishmack joined
23:20 <Eduard_Munteanu> Yes, it often means whatever action in the 'm' monad you ran just failed.
23:20 pranz2 joined
23:20 sanitypassing joined
23:21 <iqubic> Eduard_Munteanu: What should I return if I have 2 rights?
23:21 <Eduard_Munteanu> iqubic, shortcircuit
23:21 <iqubic> after the first one?
23:21 fizbin joined
23:22 exbio joined
23:22 Hunter1 joined
23:22 <iqubic> What if I get just a single Right?
23:22 <iqubic> So Left <|> Right or Right <|> Left
23:23 sanitypa1 joined
23:23 <Eduard_Munteanu> Remember that Alternative should shortcircuit to the first succcessful action.
23:24 beerdrop joined
23:24 <iqubic> What if both actions return Left?
23:24 <Eduard_Munteanu> It fails (that far).
23:24 <Eduard_Munteanu> You can try it with Maybe...
23:25 <iqubic> I don't want to.
23:25 <iqubic> I like the challenge of ExceptT
23:25 <Eduard_Munteanu> > Nothing <|> Just 2 <|> Just 3 <|> Nothing
23:25 <lambdabot> Just 2
23:25 <Eduard_Munteanu> I mean try some values.
23:25 <NickHu> Can anyone think of a neater way to write http://lpaste.net/355119 ?
23:26 bigos joined
23:26 <iqubic> If I have ExceptT x, how do I run the action of X?
23:26 exbio joined
23:26 <Eduard_Munteanu> NickHu, sequence?
23:27 <kadoban> Ya, that looks a lot like sequence
23:27 <Eduard_Munteanu> > sequence (1, [2,3,4])
23:27 <lambdabot> [(1,2),(1,3),(1,4)]
23:27 <Eduard_Munteanu> :t Data.Traversable.sequence
23:27 <lambdabot> (Monad m, Traversable t) => t (m a) -> m (t a)
23:27 <iqubic> > Right 5 <|> Right 5
23:27 <lambdabot> error:
23:27 <lambdabot> • Ambiguous type variable ‘a0’ arising from a use of ‘show_M378179776698...
23:27 <lambdabot> prevents the constraint ‘(Show a0)’ from being solved.
23:27 <iqubic> Why won't that thing work?
23:28 <iqubic> Eduard_Munteanu: Is there a way to make my thing work?
23:28 <NickHu> Oh nice!
23:28 <NickHu> I did hoogle for (a, [b]) -> [(a, b)] but it didn't come up
23:28 <kadoban> iqubic: There isn't enough context for it to figure out what type that should be, and there's not an appropriate default.
23:28 ddere joined
23:28 <Eduard_Munteanu> iqubic, the same way you did in Monad instances, for example
23:29 <iqubic> > Right 5 <|> Right 5 :: Either String Integer
23:29 <lambdabot> Right 5
23:29 <iqubic> > Right 5 <|> Right 7 :: Either String Integer
23:29 <lambdabot> Right 5
23:29 <Eduard_Munteanu> @hoogle distribute
23:29 <lambdabot> Data.Conduit.Lift distribute :: (Monad (t (ConduitM b o m)), Monad m, Monad (t m), MonadTrans t, MFunctor t) => ConduitM b o (t m) () -> t (ConduitM b o m) ()
23:29 <lambdabot> Pipes.Lift distribute :: (Monad m, MonadTrans t, MFunctor t, Monad (t m), Monad (t (Proxy a' a b' b m))) => Proxy a' a b' b (t m) r -> t (Proxy a' a b' b m) r
23:29 <lambdabot> Data.Distributive distribute :: (Distributive g, Functor f) => f (g a) -> g (f a)
23:29 <iqubic> > Right 5 <|> Left 5 :: Either String Integer
23:29 <lambdabot> error:
23:29 <lambdabot> • No instance for (Num String) arising from the literal ‘5’
23:29 <lambdabot> • In the first argument of ‘Left’, namely ‘5’
23:29 <iqubic> > Right 5 <|> Left "Err" :: Either String Integer
23:29 <lambdabot> Right 5
23:30 <iqubic> > Left "Err" <|> Right 6 :: Either String Integer
23:30 <lambdabot> Right 6
23:30 <iqubic> Why did it just skip over the first thing there?
23:30 <iqubic> > Left "Err" <|> Left "or" :: Either String Integer
23:30 <lambdabot> Left "or"
23:30 <iqubic> And why is it returning the second thing there?
23:31 <NickHu> Is there any benefit to using sequenceA over sequence in this case?
23:31 <Eduard_Munteanu> iqubic, that's Error e => Alternative (Either e)
23:31 <iqubic> Oh.
23:31 hamishmack joined
23:31 <Eduard_Munteanu> NickHu, the type is more general
23:31 <kadoban> NickHu: I don't think it should matter here specifically
23:32 <iqubic> Should my Monoid version always skip over the first thing if it
23:32 <geekosaur> NickHu, I think the only difference is that sequenceA is Applicative; since sequence only *needs* Applicative, the type of sequence is a historical wart
23:32 <iqubic> is a Left?
23:32 <Eduard_Munteanu> > Data.Distributive.distribute (1, [2,3,4])
23:32 <lambdabot> error:
23:32 <lambdabot> Not in scope: ‘Data.Distributive.distribute’
23:32 <lambdabot> No module named ‘Data.Distributive’ is imported.
23:32 <Eduard_Munteanu> @hoogle f (g a) -> g (f a)
23:32 <lambdabot> Conversion convert2 :: Conversion (a x1 x2) (b x1 x2) => a x1 x2 -> b x1 x2
23:32 <lambdabot> Darcs.Patch.Witnesses.Unsafe unsafeCoerceP :: a wX wY -> a wB wC
23:32 <lambdabot> Darcs.Patch.Witnesses.Unsafe unsafeCoercePStart :: a wX1 wY -> a wX2 wY
23:33 <NickHu> Eduard_Munteanu: I get that, but do you think it's all compiled to the same thing by ghc?
23:33 ystael joined
23:33 firef1y joined
23:33 alien8d joined
23:33 chimmihc joined
23:33 <iqubic> Should my Monoid version always skip over the first thing if it is a left?
23:34 <Eduard_Munteanu> Not sure.
23:34 lambda-11235 joined
23:34 <ertes> NickHu: some monads have a more efficient implementation of (<*>)
23:34 <Eduard_Munteanu> iqubic, well, the obvious thing would be to sum up the errors
23:34 <ertes> NickHu: … more efficient than 'ap' that is
23:34 <iqubic> What are the Alternative Laws?
23:34 <Eduard_Munteanu> iqubic, see the docs on Alternative
23:35 <ertes> NickHu: nevermind, 'sequence' probably uses (>>) anyway
23:35 <geekosaur> they should compile to equivalent things, but sequenceA might well compile to something more efficient
23:35 <hpc> the docs just say "A monoid on applicative functors"
23:35 <ertes> ah, wait… 'sequence', not 'sequence_'
23:35 <hpc> so you have to do a bit of thinking on your own to arrive at the laws
23:35 <geekosaur> if they don't compile to equivalent things then someone's Applicative instance doesn't match their Monad instance which is a law violation
23:35 <hpc> https://hackage.haskell.org/package/base- - the Monoid laws
23:35 <NickHu> geekosaur: Why might the more general one compile to something more efficient as opposed to the more specialised one?
23:36 <hpc> let mempty = empty, mappend = (<|>)
23:36 <hpc> and you have the Alternative laws
23:36 <Eduard_Munteanu> Well, you have the Monoid laws and something extra that makes sense for an Applicative.
23:36 <ertes> NickHu: it's not about being more general, but (<*>) is just a more fitting combinator for the use case
23:36 <geekosaur> NickHu, because the more specialized one has in this case to "regain" Applicative via Monad, so it may be doing silly things
23:36 <hpc> (as well as the "laws" for some and many, which are basically just a default implementation)
23:36 <geekosaur> like we have to regain join via (>>= id)
23:37 <Eduard_Munteanu> Such that it's a bit more than applicative plus monoid.
23:37 <ertes> NickHu: sequence (c:cs) = c >>= \x -> fmap (x :) sequence cs
23:37 <ertes> NickHu: sequenceA (c:cs) = fmap (:) c <*> sequenceA cs
23:38 <iqubic> hpc: Wha about empty <|> x = x
23:38 firef1y joined
23:38 <Eduard_Munteanu> iqubic, that's a monoid law... mempty `mappend` x = x
23:39 <NickHu> geekosaur: I see
23:39 <NickHu> So in principle, the more specialised one can be more efficient
23:39 <NickHu> But in this particular case, it's possible the inverse is true
23:39 <ertes> geekosaur: actually, post-AMP 'sequence' might be exactly the same thing as 'sequenceA'
23:39 robatosan joined
23:39 <geekosaur> NickHu, right
23:39 <NickHu> (List monad/applicative)
23:39 <NickHu> Right?
23:39 <iqubic> Eduard_Munteanu: Does my Alternative need to follow that law?
23:40 <geekosaur> specialization can open a path to use a more optimized form but it can also cut off other optimization paths
23:40 niteria joined
23:40 <Eduard_Munteanu> iqubic, yes
23:40 <NickHu> Why is this true for the List instances?
23:40 <geekosaur> which one matters more tends to be case-by-case
23:40 <ertes> NickHu: (<*>) is a better fit to the problem… it's not about expressiveness, but about "how much extra stuff do i need to do when using this combinator?"
23:40 <NickHu> Is it something GHC specific about how they are implemented, or is there something more fundamental here?
23:41 SeMas joined
23:41 <iqubic> Why is it so hard to write an Alternative instance?
23:41 <ertes> also (>>=) is generally more sequential in nature
23:41 <geekosaur> mostly it's that Applicative didn't exist when Monad and things like sequence were defined. so sequence is defined the way it had to be for that "world"
23:41 <geekosaur> in a world that has Applicative, you have more possibilities
23:42 <Eduard_Munteanu> :t Control.Monad.sequence
23:42 <lambdabot> (Monad m, Traversable t) => t (m a) -> m (t a)
23:42 <Eduard_Munteanu> Hrmpf.
23:42 <NickHu> So if GHC were reimplemented today, things would be different
23:42 <geekosaur> like i said, historical wart. not in GHC so much as in Haskell, since it was so late on recognizing that Monad should have been based on Applicative in the first place
23:42 <Eduard_Munteanu> :t Data.List.sequence
23:42 <lambdabot> error:
23:42 <lambdabot> Not in scope: ‘Data.List.sequence’
23:42 <lambdabot> Perhaps you meant one of these:
23:43 <ertes> > ping
23:43 <lambdabot> pong
23:43 <NickHu> I've heard it said that monads are only lax monoidal functors in Hask, which Haskell approximates
23:43 <Eduard_Munteanu> @more
23:43 <lambdabot> Plugin `more' failed with: Prelude.init: empty list
23:43 <NickHu> In category theoretic terms, what property causes that?
23:44 <Eduard_Munteanu> No, don't confuse that with Applicatives.
23:44 <Eduard_Munteanu> Applicatives are lax monoidal functors.
23:45 <NickHu> Eduard_Munteanu: I mean point 3 here https://github.com/mikeizbicki/subhask#functor-hierarchy
23:46 nakal_ joined
23:47 <ertes> for many monads (<*>) can be parallel… not necessarily operationally, but it gives the compiler more options regarding evaluation order
23:47 <Eduard_Munteanu> Well, it just happens that Monads are Applicatives in Hask.
23:47 <ertes> i don't know how much GHC actually uses that information though
23:47 Big_G joined
23:47 <Eduard_Munteanu> Or can be made so. But in other categories it might not be true.
23:47 markus1189 joined
23:47 markus1199 joined
23:47 nh2 joined
23:48 <Eduard_Munteanu> More generally, applicatives and monads are unrelated.
23:48 oleo joined
23:50 butterthebuddha joined
23:51 <NickHu> Eduard_Munteanu: Yes, my specific question is why does that relationship exist in Hask? Is there some nice property of Hask that causes it?
23:51 beerdrop joined
23:52 darjeeling_ joined
23:52 _ashbreeze_ joined
23:52 <Eduard_Munteanu> Well, I'm not sure, but it's cartesian-closed for a start, so it's got all exponentials.
23:52 theDon_ joined
23:52 <Eduard_Munteanu> :t (<*>)
23:52 <lambdabot> Applicative f => f (a -> b) -> f a -> f b
23:53 takle joined
23:53 <Eduard_Munteanu> :t liftA2 ($)
23:53 <lambdabot> Applicative f => f (a -> c) -> f a -> f c
23:54 biglambda joined
23:55 <Eduard_Munteanu> :t liftM2 ($)
23:55 <lambdabot> Monad m => m (a -> r) -> m a -> m r
23:55 mithrandeer joined
23:57 firef1y joined
23:57 <Eduard_Munteanu> Applicatives are sort of exponential-preserving functors.
23:58 infinity0_ joined
23:58 infinity0_ joined