Logs: freenode/#haskell
| 2021-05-11 21:50:53 | <geekosaur> | nineonin_, flip? |
| 2021-05-11 21:50:56 | → | rzmt joins (~rzmt@87-92-180-112.rev.dnainternet.fi) |
| 2021-05-11 21:51:38 | ← | olle parts (~olle@i5E8666E4.versanet.de) () |
| 2021-05-11 21:51:56 | → | jluttine joins (~jluttine@85-23-66-6.bb.dnainternet.fi) |
| 2021-05-11 21:52:07 | × | stree quits (~stree@68.36.8.116) (Ping timeout: 252 seconds) |
| 2021-05-11 21:52:21 | × | rj quits (~x@gateway/tor-sasl/rj) (Ping timeout: 240 seconds) |
| 2021-05-11 21:52:22 | <Ernest> | So is (->) a type constrcutor kind of like IO is a type constructor? Am I using the term type constructor correctly? |
| 2021-05-11 21:52:25 | <nineonin_> | hmm |
| 2021-05-11 21:52:35 | <ski> | Ernest : yes |
| 2021-05-11 21:53:21 | → | nbloomf joins (~nbloomf@2600:1700:ad14:3020:692a:95b:a9cd:2f9) |
| 2021-05-11 21:53:26 | <nineonin_> | geekosaur, so how would it look like? |
| 2021-05-11 21:54:43 | → | hypercube joins (~hypercube@75.186.121.128) |
| 2021-05-11 21:55:23 | × | fendor quits (~fendor@178.165.129.215.wireless.dyn.drei.com) (Quit: Leaving) |
| 2021-05-11 21:55:52 | <geekosaur> | (flip Map.unions) in place of Map.unions |
| 2021-05-11 21:56:09 | <geekosaur> | you could even name it: unionr = flip Map.unions |
| 2021-05-11 21:56:21 | <geekosaur> | then use unionr wherever you want the right-biased union |
| 2021-05-11 21:56:31 | <ski> | Ernest : you have to apply `(->)' to two type expressions, just like you have to for `Either', in order to get a concrete type back (that can be the type of a value, that can be written to the right of `::') |
| 2021-05-11 21:56:37 | <nineonin_> | unions :: (Foldable f, Ord k) => f (Map k a) -> Map k a |
| 2021-05-11 21:57:12 | <nineonin_> | not sure what to flip here |
| 2021-05-11 21:57:21 | × | __monty__ quits (~toonn@unaffiliated/toonn) (Quit: leaving) |
| 2021-05-11 21:57:33 | <geekosaur> | oh, I'm thinking union. unions… would need to reverse the list |
| 2021-05-11 21:57:39 | <nineonin_> | but maybe this will work with unionsWith (flip union) |
| 2021-05-11 21:57:52 | <nineonin_> | flip is the way to go though |
| 2021-05-11 21:57:53 | <nineonin_> | thanks! |
| 2021-05-11 21:59:46 | <Ernest> | @ski Ah cool. Now my mind looping back to how can a type constructor that doesn't really hold data have an fmap instance, but I have taken note of what has been said earlier and will chew on it |
| 2021-05-11 21:59:47 | <lambdabot> | Maybe you meant: wiki src ask |
| 2021-05-11 21:59:56 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-05-11 22:00:28 | → | Rudd0 joins (~Rudd0@185.189.115.108) |
| 2021-05-11 22:01:43 | <ski> | Ernest : "data type" here means a type whose values are constructed by data constructors |
| 2021-05-11 22:02:00 | <monochrom> | What you're seeing is that Functor is so general it is not just for "data" "structures". |
| 2021-05-11 22:02:15 | → | janne- joins (~janne@punainen.org) |
| 2021-05-11 22:02:23 | <monochrom> | "data structures" is a social construct. |
| 2021-05-11 22:02:25 | <alphabeta1> | Is (->) not a data constructor that takes 2 types though? |
| 2021-05-11 22:02:26 | × | _janne quits (~janne@punainen.org) (Ping timeout: 245 seconds) |
| 2021-05-11 22:02:40 | <ski> | Ernest : a function still "holds" data (its potential outputs, for each potential input we could call it with), in a generalized sense |
| 2021-05-11 22:02:43 | <monochrom> | The terminology is "type constructor". |
| 2021-05-11 22:02:47 | <ski> | alphabeta1 : no |
| 2021-05-11 22:02:56 | <monochrom> | "data constructor" is for Left, Right, Just, Nothing. |
| 2021-05-11 22:03:05 | <monochrom> | "type constructor" is for Either, Maybe. |
| 2021-05-11 22:03:22 | <alphabeta1> | Ah! |
| 2021-05-11 22:03:28 | → | usr25 joins (~J@41.red-83-58-207.dynamicip.rima-tde.net) |
| 2021-05-11 22:03:29 | <monochrom> | For convenience in wording, we also accept Int as a type constructor. |
| 2021-05-11 22:03:36 | ski | again laments the common convention to name the type constructor the same as the data constructor, in case there's only one of the latter |
| 2021-05-11 22:04:32 | <monochrom> | Yeah I never do "data X = X Int" in front of me students. Only "data X = MkX Int". |
| 2021-05-11 22:04:34 | × | hyiltiz quits (~quassel@unaffiliated/hyiltiz) (Ping timeout: 245 seconds) |
| 2021-05-11 22:04:45 | × | mikoto-chan quits (~mikoto-ch@gateway/tor-sasl/mikoto-chan) (Ping timeout: 240 seconds) |
| 2021-05-11 22:05:05 | → | stree joins (~stree@68.36.8.116) |
| 2021-05-11 22:05:12 | <monochrom> | "data X = X Int" is cute for professional programmers who understand it, but it sends the wrong message to students. |
| 2021-05-11 22:05:26 | → | hyiltiz joins (~quassel@unaffiliated/hyiltiz) |
| 2021-05-11 22:05:34 | <monochrom> | There are a few other legal things in the same genre. |
| 2021-05-11 22:06:00 | <hpc> | counterpoint: in java - class is Foo, constructor is new Foo() |
| 2021-05-11 22:06:10 | <ski> | Ernest : may i remind you again of how values of type `(Int,Int)' hold the same information as values of type `Bool -> Int' (can you write two transformation functions between these two types, each undoing the other ?) ? |
| 2021-05-11 22:07:06 | <Ernest> | Int + Int == Bool * Int, something like that? |
| 2021-05-11 22:07:13 | <monochrom> | The #1 confusing thing is "x = do ..." and ending with "where ..." at column > 6. Sends the wrong message that the "where" is part of the "do". |
| 2021-05-11 22:07:20 | <Ernest> | Since bool is 2 |
| 2021-05-11 22:08:06 | <ski> | Ernest : something like that conceptual equality, yes (although that was for `Either Int Int' vs. `(Bool,Int)', which is not quite the example what i was talking about) |
| 2021-05-11 22:08:37 | × | urdh quits (~urdh@unaffiliated/urdh) (Ping timeout: 252 seconds) |
| 2021-05-11 22:08:59 | → | cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net) |
| 2021-05-11 22:09:22 | <ski> | Int × Int = Int² |
| 2021-05-11 22:10:12 | → | urdh joins (~urdh@unaffiliated/urdh) |
| 2021-05-11 22:10:20 | <Ernest> | Ah and function application is exponentation |
| 2021-05-11 22:10:47 | → | mikoto-chan joins (~mikoto-ch@gateway/tor-sasl/mikoto-chan) |
| 2021-05-11 22:11:01 | <ski> | Ernest : if you can think of `(Int,Int)' (or `Pair Int', where `data Pair a = Couple a a') as a container holding two `Int's, then you can also think of `Bool -> Int' as a "container" holding two `Int's |
| 2021-05-11 22:11:43 | <ski> | Ernest : no, the function arrow (`A -> B') is (converse) exponentiation (⌜Bᴬ⌝) |
| 2021-05-11 22:13:25 | <m_shiraeeshi> | how about a newtype? naming the newtype the same as a data constructor |
| 2021-05-11 22:13:37 | <Ernest> | I encountered a little bit of the idea in Thinking with Types by Sandy Maguire, but I realised I shouldve gotten a bit more experience with the vanilla type system as the book goes into the different type extensions |
| 2021-05-11 22:13:38 | <m_shiraeeshi> | it allows only one constructor |
| 2021-05-11 22:14:51 | × | vent quits (~vent@185.62.190.213) (Quit: ZNC - http://znc.in) |
| 2021-05-11 22:14:59 | <monochrom> | The point, at least my point, is about misleading students to conflate types with terms, not about uniqueness vs non-uniqueness. |
| 2021-05-11 22:16:18 | <m_shiraeeshi> | I add the "Data" suffix for data declarations |
| 2021-05-11 22:16:29 | <monochrom> | You need to run into 10 students in a row who do "I'm trying data X = Int | Char and newtype Y = Double, why are they not working?" to understand it. |
| 2021-05-11 22:16:31 | <m_shiraeeshi> | like data SomethingData = X | Y |
| 2021-05-11 22:16:54 | <ski> | m_shiraeeshi : i object as much to it, for `newtype's, yes |
| 2021-05-11 22:17:02 | → | notzmv joins (~zmv@unaffiliated/zmv) |
| 2021-05-11 22:17:12 | × | Gurkenglas quits (~Gurkengla@unaffiliated/gurkenglas) (Ping timeout: 252 seconds) |
| 2021-05-11 22:17:29 | × | apache8080 quits (~rishi@wsip-70-168-153-252.oc.oc.cox.net) (Ping timeout: 245 seconds) |
| 2021-05-11 22:17:30 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2021-05-11 22:17:38 | <m_shiraeeshi> | but the "NewType" suffix seems too long |
| 2021-05-11 22:17:41 | × | oxide quits (~lambda@unaffiliated/mclaren) (Ping timeout: 240 seconds) |
| 2021-05-11 22:17:42 | <ski> | (and for similar reasons i also object to the notation for tuple types) |
| 2021-05-11 22:17:47 | <Ernest> | If you want some more feedback from a student: I didn't have an understanding of the prescedence of things clearly enough for a long time which made learning much more complex |
| 2021-05-11 22:18:11 | <monochrom> | Oh this is why the consensus is "if you want to do it monochrom's way, use the Mk prefix". |
| 2021-05-11 22:18:12 | <ski> | newtype State s a = MkState {runState :: s -> (s,a)} -- what i'd prefer |
| 2021-05-11 22:18:20 | → | oxide joins (~lambda@unaffiliated/mclaren) |
| 2021-05-11 22:18:25 | <alphabeta1> | Oh yeah, Mk is what I learnt at uni too |
| 2021-05-11 22:18:38 | × | tromp quits (~tromp@dhcp-077-249-230-040.chello.nl) (Remote host closed the connection) |
| 2021-05-11 22:18:38 | <alphabeta1> | used to read it as mukk but it turned out it was short for Make |
| 2021-05-11 22:18:39 | <monochrom> | I would really love the Of suffix, but it didn't take off. |
| 2021-05-11 22:18:49 | <ski> | if you can thing of an appropriate different name for the data constructor, you can use that. you don't need to use `Mk..' (or `..Of') |
| 2021-05-11 22:19:11 | <monochrom> | Oh, "data X = MuckingWithX Int" is a fine reading too. |
| 2021-05-11 22:19:33 | <alphabeta1> | Hahaha monochrom, that made me laugh. |
| 2021-05-11 22:19:38 | <ski> | m_shiraeeshi : "I add the \"Data\" suffix for data declarations" -- how do you mean ? |
| 2021-05-11 22:19:43 | <monochrom> | Since in pattern matching it becomes "f (I'm mucking with X i) = i+1" is exactly what you're doing >:) |
| 2021-05-11 22:19:56 | <m_shiraeeshi> | ski: data SomethingData = X | Y |
| 2021-05-11 22:20:30 | <ski> | m_shiraeeshi : that seems like a case of hungarian (in the bad sense) |
| 2021-05-11 22:20:33 | ← | justsomeguy parts (~justsomeg@unaffiliated/--/x-3805311) ("WeeChat 3.0.1") |
| 2021-05-11 22:21:06 | <ski> | (note me saying `data Pair a = Couple a a' rather than `data Pair a = MkPair a a' above) |
| 2021-05-11 22:21:12 | × | ddellaco_ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Remote host closed the connection) |
| 2021-05-11 22:22:11 | → | ddellaco_ joins (~ddellacos@ool-44c73afa.dyn.optonline.net) |
| 2021-05-11 22:22:15 | → | shane joins (~shane@desk.roadwar.net) |
All times are in UTC.