Logs: freenode/#haskell
| 2021-04-09 15:16:15 | <honigkuchen> | :) |
| 2021-04-09 15:16:29 | → | justanotheruser joins (~justanoth@unaffiliated/justanotheruser) |
| 2021-04-09 15:16:30 | <juri_> | hey, i have couple of files i've written, that i would like a look over to try and tell me how to better (ab)use types. https://github.com/julialongtin/hslice/blob/master/Graphics/Slicer/Math/GeometricAlgebra.hs , and it's consumer, https://github.com/julialongtin/hslice/blob/master/Graphics/Slicer/Math/PGA.hs . I should name the consumer 2DPGA.hs, and would like to write a 3DPGA.hs... but i would like to |
| 2021-04-09 15:16:36 | <juri_> | limit options of my GVec contents based on whether i'm using a PLine2 or a (hypothetical) PLine3. right now, it accepts any GVal of GNum (G0, GEPlus, GEZero, GEMinus), even tho for a PLine2, GEMinus is not allowed. |
| 2021-04-09 15:17:08 | <juri_> | tl;dr: i can projective geometric algebra, but types are hard. |
| 2021-04-09 15:17:13 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-04-09 15:17:41 | → | LKoen joins (~LKoen@65.250.88.92.rev.sfr.net) |
| 2021-04-09 15:18:10 | <hyperisco> | honigkuchen, type unification, for example |
| 2021-04-09 15:18:11 | <ski> | honigkuchen : i guess you could say that higher-rank operations are based on the concept of (parametric) polymorphism |
| 2021-04-09 15:18:59 | <ski> | unification is an implementation issue (of type checking/inference) |
| 2021-04-09 15:20:13 | <hyperisco> | it is based on symbolic equations, how would that not qualify? polymorphism typically involves symbolic expressions |
| 2021-04-09 15:20:22 | → | kaction joins (~kaction@ppsr.interfacefinancial.com) |
| 2021-04-09 15:20:41 | → | frozenErebus joins (~frozenEre@37.231.244.249) |
| 2021-04-09 15:21:17 | <honigkuchen> | great |
| 2021-04-09 15:21:30 | <honigkuchen> | is type unification part of prolog? |
| 2021-04-09 15:21:36 | <ski> | implementing (type checking/inference of) (parametric) polymorphism typically involves unification |
| 2021-04-09 15:21:39 | <ski> | honigkuchen : no |
| 2021-04-09 15:21:52 | <ski> | Prolog doesn't have a static type system |
| 2021-04-09 15:22:23 | × | royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 265 seconds) |
| 2021-04-09 15:22:25 | <hyperisco> | I was just interpreting "based on" as "depends on", not "generalises" |
| 2021-04-09 15:22:47 | <honigkuchen> | is type unification part of haskell? |
| 2021-04-09 15:22:58 | <hyperisco> | yes |
| 2021-04-09 15:22:58 | <ski> | however, unification of terms in Prolog is very similar to unification of types in (e.g.) Haskell (or SML,OCaml,F#,Mercury,..) |
| 2021-04-09 15:23:06 | × | acidjnk_new quits (~acidjnk@p200300d0c72b9564e895d5f110e04519.dip0.t-ipconnect.de) (Ping timeout: 258 seconds) |
| 2021-04-09 15:23:15 | × | notzmv quits (~zmv@unaffiliated/zmv) (Ping timeout: 260 seconds) |
| 2021-04-09 15:23:51 | <ski> | unification in Prolog is also an implementation issue, it's how equality is implemented, it's how repeated mentions of a variable are implemented |
| 2021-04-09 15:23:59 | <hyperisco> | if you wanted to generalise polymorphism I am not sure what direction that would take… it is like asking how can you generalise variables |
| 2021-04-09 15:24:10 | <hyperisco> | (combinators, obviously) |
| 2021-04-09 15:24:40 | <honigkuchen> | thx, I think my question became very good answered. :) |
| 2021-04-09 15:25:01 | lep_ | is now known as lep-delete |
| 2021-04-09 15:25:18 | × | frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 240 seconds) |
| 2021-04-09 15:25:39 | <ski> | well, you could make it into a first-class thing, just like higher-order functions make functions into first-class values. doing this leads to higher-rank operations (operations that take as argument a polymorphic (or higher-rank, in general) operation/callback) |
| 2021-04-09 15:26:26 | <hyperisco> | so RankNTypes |
| 2021-04-09 15:26:29 | × | sedeki quits (~textual@unaffiliated/sedeki) (Quit: Textual IRC Client: www.textualapp.com) |
| 2021-04-09 15:26:37 | <ski> | not sure whether that would be thought of as "generalise polymorphism", but one could argue it's "a concept based on polymorphism" |
| 2021-04-09 15:26:43 | → | Sgeo_ joins (~Sgeo@ool-18b98aa4.dyn.optonline.net) |
| 2021-04-09 15:28:11 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-04-09 15:28:12 | × | Sgeo quits (~Sgeo@ool-18b98aa4.dyn.optonline.net) (Ping timeout: 240 seconds) |
| 2021-04-09 15:28:29 | <ski> | unification in Prolog is "just" an "efficiency hack" (but a rather crucial one). one can explain the declarative semantics of a (pure declarative) Prolog program, without referring to concepts like "unification". that's part of what i meant by it being "merely" an implementation issue |
| 2021-04-09 15:28:46 | × | Synthetica quits (uid199651@gateway/web/irccloud.com/x-ozqppwfawxsanypt) (Quit: Connection closed for inactivity) |
| 2021-04-09 15:29:25 | <ski> | (and unification of types in the Hindley-Milner type system, or type systems based on it (like Haskell's), plays a similar rôle in that context) |
| 2021-04-09 15:30:43 | <hyperisco> | polymorphism does not depend on unification, agreed |
| 2021-04-09 15:31:01 | ski | . o O ( "Polymorphic Type Inference" by Michael I. Schwartzbach in 1995-03 at <https://cs.au.dk/~amoeller/mis/typeinf.p(s|df)>,<https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.57.1493> ) |
| 2021-04-09 15:31:18 | → | geekosaur joins (42d52137@66.213.33.55) |
| 2021-04-09 15:31:53 | → | Guest182 joins (~laudiacay@67.176.215.84) |
| 2021-04-09 15:31:56 | <ski> | (and unification doesn't depend on polymorphism) |
| 2021-04-09 15:32:23 | → | Sgeo__ joins (~Sgeo@ool-18b98aa4.dyn.optonline.net) |
| 2021-04-09 15:32:45 | <hyperisco> | type unification more specifically does, or otherwise I am not sure what work there is to be done |
| 2021-04-09 15:33:26 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-09 15:33:42 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 268 seconds) |
| 2021-04-09 15:35:38 | × | Sgeo_ quits (~Sgeo@ool-18b98aa4.dyn.optonline.net) (Ping timeout: 268 seconds) |
| 2021-04-09 15:35:57 | → | jakalx joins (~jakalx@base.jakalx.net) |
| 2021-04-09 15:36:00 | → | tzh joins (~tzh@24.21.73.154) |
| 2021-04-09 15:37:16 | → | idhugo joins (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net) |
| 2021-04-09 15:37:49 | × | heatsink quits (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 252 seconds) |
| 2021-04-09 15:38:05 | × | idhugo quits (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net) (Remote host closed the connection) |
| 2021-04-09 15:38:31 | → | idhugo joins (~idhugo@87-49-147-45-mobile.dk.customer.tdc.net) |
| 2021-04-09 15:39:21 | → | frozenErebus joins (~frozenEre@37.231.244.249) |
| 2021-04-09 15:39:46 | × | Sgeo__ quits (~Sgeo@ool-18b98aa4.dyn.optonline.net) (Ping timeout: 240 seconds) |
| 2021-04-09 15:39:54 | → | chenshen joins (~chenshen@2620:10d:c090:400::5:d7c6) |
| 2021-04-09 15:41:09 | → | shalokshalom joins (~quassel@2a02:1748:dd5e:7f60:cf49:8384:7c93:3106) |
| 2021-04-09 15:42:18 | → | heatsink joins (~heatsink@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-04-09 15:44:42 | <ski> | the implementation doesn't depend on the feature being implemented. that would be circular |
| 2021-04-09 15:46:41 | → | thblt joins (~thblt@unaffiliated/thblt) |
| 2021-04-09 15:47:11 | × | waleee-cl quits (uid373333@gateway/web/irccloud.com/x-ljutfegkxznelovf) (Quit: Connection closed for inactivity) |
| 2021-04-09 15:47:21 | → | Sgeo joins (~Sgeo@ool-18b98aa4.dyn.optonline.net) |
| 2021-04-09 15:47:24 | × | dcbdan quits (~dcbdan@c-73-76-129-120.hsd1.tx.comcast.net) (Quit: leaving) |
| 2021-04-09 15:47:31 | × | NinjaTrappeur quits (~ninja@unaffiliated/ninjatrappeur) (Ping timeout: 248 seconds) |
| 2021-04-09 15:48:27 | × | frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 260 seconds) |
| 2021-04-09 15:50:00 | <thblt> | Stupid question I'm not sure how to phrase. It seems a common pattern to write recursive types of kind *, eg to model expressions. |
| 2021-04-09 15:50:03 | <thblt> | In my case, I'm writing a simple solver for logical expressions, so i have data Expr = T | F | And Expr Expr | Or Expr Expr | Variable Char (simplified). It would seem *very* natural to make it Foldable, Traversable, etc (eg to collect variable names, or replace variables with values to calculate a truth table, and so on). |
| 2021-04-09 15:50:06 | <thblt> | But I can't, because its kind is *, not * -> *. Should I make Expr parameterizable over its variable type, or is there another pattern I'm missing? |
| 2021-04-09 15:50:36 | <thblt> | Thanks, and sorry for the Reddit-length message :) |
| 2021-04-09 15:51:59 | <c_wraith> | I'm not sure it's as natural as you think |
| 2021-04-09 15:52:01 | <ski> | it can sometimes make sense to parameterize over (free) variable type |
| 2021-04-09 15:52:06 | × | zebrag quits (~inkbottle@aaubervilliers-654-1-2-51.w83-200.abo.wanadoo.fr) (Quit: Konversation terminated!) |
| 2021-04-09 15:52:25 | → | zebrag joins (~inkbottle@aaubervilliers-654-1-2-51.w83-200.abo.wanadoo.fr) |
| 2021-04-09 15:52:52 | <c_wraith> | a key part of Traversable is that it allows changing the type of something, and it guarantees that the implementation cannot depend on the types that it can change |
| 2021-04-09 15:52:55 | → | bitmagie joins (~Thunderbi@200116b8066d480018b10679a2cb4b2e.dip.versatel-1u1.de) |
| 2021-04-09 15:52:59 | <ski> | (you could even make it an instance of `Monad' then, possibly) |
| 2021-04-09 15:53:42 | <c_wraith> | If your type doesn't have places where it makes sense to change types, then Traversable/Functor/Applicative/Monad don't make sense |
| 2021-04-09 15:54:00 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:bc0d:525e:2ac7:f5de) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-04-09 15:54:25 | × | bitmagie quits (~Thunderbi@200116b8066d480018b10679a2cb4b2e.dip.versatel-1u1.de) (Client Quit) |
| 2021-04-09 15:55:10 | <thblt> | ski: c_wraith: thanks! |
| 2021-04-09 15:55:53 | <c_wraith> | that doesn't mean you can't get value from some sort of genericized traversal. Just that it isn't going to use those classes |
| 2021-04-09 15:56:12 | <c_wraith> | One place it's easy to turn to is recursion schemes |
| 2021-04-09 15:56:30 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-04-09 15:57:18 | <thblt> | c_wraith: that's my issue, I believe. I feel like I'm reinventing fold and map outside of Foldable and Functor. Parameterizing over the free variable type is an option, but indeed that type isn't going to change. |
| 2021-04-09 15:57:40 | <thblt> | I need to think about it a bit more :) |
| 2021-04-09 15:57:59 | × | chele quits (~chele@ip5b40237d.dynamic.kabel-deutschland.de) (Remote host closed the connection) |
| 2021-04-09 15:58:29 | <hyperisco> | thblt, well you aren't really reinventing anything, because fold and map are just class members, not already implemented |
| 2021-04-09 15:58:52 | <c_wraith> | you can also take inspiration from systems like monotraversable or lens, depending on the kinds of ecosystems you want to fit in with |
| 2021-04-09 15:58:59 | <hyperisco> | ie if you were writing a class instance you'd be implementing them just the same (with possible GHC deriving help) |
| 2021-04-09 15:59:28 | → | nbloomf joins (~nbloomf@2600:1700:ad14:3020:bc0d:525e:2ac7:f5de) |
| 2021-04-09 16:00:03 | × | psydruid quits (psydruidma@gateway/shell/matrix.org/x-yhgzbwrfmdfoyowz) (Quit: Idle for 30+ days) |
| 2021-04-09 16:00:09 | <thblt> | hyperisco: yes of course. What feels like I may be hitting an antipattern is implementing (not inventing, indeed) them outside of their respective typeclasses. But maybe I'm giving to much importance to mere similarity. |
| 2021-04-09 16:00:22 | <hyperisco> | the main point of classes is to use them generically, not specialised to one type |
| 2021-04-09 16:00:42 | → | cheater1 joins (~user@unaffiliated/cheater) |
| 2021-04-09 16:01:12 | <hyperisco> | if there is machinery that operates generically on Traversable, say, and you want to take advantage of it, then that is good reason to desire a Traversable |
| 2021-04-09 16:01:47 | <thblt> | Thank you all :) |
All times are in UTC.