Logs: freenode/#haskell
| 2020-11-06 22:58:40 | <ski> | the observe how the four implementations of circumference/area for rectangle/circle are distributed differently in these two different implementations. then you could try maybe adding a new alternative, maybe triangle (say you give the three side lengths. use Heron's formula for area), as well as adding a new property. hm, maybe the radius of the largest circle you could inscribe inside it (or of the |
| 2020-11-06 22:58:46 | <ski> | smallest circle you could circumscribe around it). you'd have to think a little about how to do it for the triangle, i guess |
| 2020-11-06 22:59:33 | → | codygman joins (~codygman@2600:380:f952:a05a:195d:2af8:616e:ca86) |
| 2020-11-06 23:00:15 | <ski> | anyway, this is just a suggestion. you don't have to do it, if it sounds too involved. perhaps you can think of some other interesting alternative or property. one cool property would be a method to actually render the shape on some graphical canvas or something. but then you'd have to dive into some graphical library |
| 2020-11-06 23:00:21 | × | Stanley00 quits (~stanley00@unaffiliated/stanley00) (Ping timeout: 256 seconds) |
| 2020-11-06 23:00:37 | × | jff quits (~Thunderbi@a109-49-149-2.cpe.netcabo.pt) (Quit: jff) |
| 2020-11-06 23:00:49 | → | jff joins (~Thunderbi@a109-49-149-2.cpe.netcabo.pt) |
| 2020-11-06 23:04:08 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2020-11-06 23:04:18 | → | nbloomf joins (~nbloomf@2600:1700:ad14:3020:2d48:c414:1e60:fe62) |
| 2020-11-06 23:04:45 | × | jff quits (~Thunderbi@a109-49-149-2.cpe.netcabo.pt) (Ping timeout: 240 seconds) |
| 2020-11-06 23:05:17 | <ski> | btw, the trade-off i expressed, between product/record types, and sum/variant types, is quite similar to the notion of shallow vs. deep embedding of an embedded domain-specific language (EDSL) |
| 2020-11-06 23:05:24 | <ski> | @wiki Embedded domain specific language |
| 2020-11-06 23:05:24 | <lambdabot> | https://wiki.haskell.org/Embedded_domain_specific_language |
| 2020-11-06 23:07:21 | → | Tario joins (~Tario@201.192.165.173) |
| 2020-11-06 23:10:20 | <ski> | (however, often the "shallow" embedding is just expressed as implementing the type of your EDSL expressions as the "main interpretation". for a parser, this might be a function of type `String -> Maybe (a,String)' (where `a' is the parse result of the parser). however, sometimes one also want to compute other "properties" or "alternative interpretations", which would then be other |
| 2020-11-06 23:10:26 | <ski> | fields/methods/slots/components, alongside the main one, in a product/record type. e.g., for a parser, you might want (for optimization purposes) a (`nullable') `Bool' to express whether a parser can succeed, while consuming no input, and a (`first') `[Char]', to express what the initial character could possibly be, if the parser is to have any chance of succeeding) |
| 2020-11-06 23:11:35 | × | conal quits (~conal@198.8.81.71) (Quit: Computer has gone to sleep.) |
| 2020-11-06 23:11:44 | × | Franciman quits (~francesco@host-79-36-167-172.retail.telecomitalia.it) (Quit: Leaving) |
| 2020-11-06 23:11:57 | → | ensyde joins (~ensyde@99-185-235-117.lightspeed.chrlnc.sbcglobal.net) |
| 2020-11-06 23:13:28 | × | AlterEgo- quits (~ladew@124-198-158-163.dynamic.caiway.nl) (Quit: Leaving) |
| 2020-11-06 23:14:30 | hackage | sexp-grammar 2.3.0 - Invertible grammar combinators for S-expressions https://hackage.haskell.org/package/sexp-grammar-2.3.0 (EugeneSmolanka) |
| 2020-11-06 23:16:30 | hackage | persistent-documentation 0.1.0.2 - Documentation DSL for persistent entities https://hackage.haskell.org/package/persistent-documentation-0.1.0.2 (parsonsmatt) |
| 2020-11-06 23:16:38 | × | ensyde quits (~ensyde@99-185-235-117.lightspeed.chrlnc.sbcglobal.net) (Ping timeout: 256 seconds) |
| 2020-11-06 23:18:50 | × | raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 256 seconds) |
| 2020-11-06 23:21:12 | → | ensyde joins (~ensyde@99-185-235-117.lightspeed.chrlnc.sbcglobal.net) |
| 2020-11-06 23:24:14 | → | conal joins (~conal@198.8.81.71) |
| 2020-11-06 23:25:22 | → | jakob_ joins (~textual@p200300f49f162200ecd950d27480ddce.dip0.t-ipconnect.de) |
| 2020-11-06 23:28:07 | × | xerox_ quits (~xerox@unaffiliated/xerox) (Ping timeout: 256 seconds) |
| 2020-11-06 23:28:35 | → | xerox_ joins (~xerox@unaffiliated/xerox) |
| 2020-11-06 23:32:02 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2020-11-06 23:32:51 | <cohn> | ski: ok, product type implementation: https://dpaste.org/M7vG |
| 2020-11-06 23:33:14 | <cohn> | working on the sum type. |
| 2020-11-06 23:34:26 | <ski> | > pi |
| 2020-11-06 23:34:28 | <lambdabot> | 3.141592653589793 |
| 2020-11-06 23:35:07 | <ski> | (seems to me the rectangular circumference, and the circular area, isn't quite right) |
| 2020-11-06 23:35:17 | × | britva quits (~britva@31-10-157-156.cgn.dynamic.upc.ch) (Quit: This computer has gone to sleep) |
| 2020-11-06 23:35:19 | × | twopoint718 quits (~cjw@fsf/member/twopoint718) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-06 23:36:22 | → | falafel joins (~falafel@2601:247:c400:1390:7811:313f:d0f3:f9f4) |
| 2020-11-06 23:36:49 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 264 seconds) |
| 2020-11-06 23:37:17 | <cohn> | yep, easy fix |
| 2020-11-06 23:38:04 | <ski> | btw, note that `rectangle' is corresponding to an OO class (it contains the implementations of the methods `circumference' and `area'), and also corresponds to its class constructor (it takes the parameters `width',`height', which acts like (private) instance variables) |
| 2020-11-06 23:38:22 | <ski> | (and similarly for `circle' with its `radius' parameter) |
| 2020-11-06 23:40:32 | → | whatisRT joins (~whatisRT@2002:5b41:6a33:0:dea6:32ff:fe5b:d45f) |
| 2020-11-06 23:40:38 | → | raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) |
| 2020-11-06 23:41:07 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:2d48:c414:1e60:fe62) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-06 23:41:09 | <ski> | (and if you think you want mutable state in your objects, it's quite easy to have the "class constructor" (the function producing your object) to allocate some mutable cell(s), with `IO', and have some methods (with `IO Something' as return type) read from and write into it -- at least once you're a bit familiar with how `IO' works, and can figure out how to use `IORef' (or `IOArray', if you prefer)) |
| 2020-11-06 23:43:08 | <ski> | i think it's good to explicitly point out how one can "do OO", at least to some extent, in Haskell. of course, if you want implementation inheritance, possibly even with open recursion, then it'll be a little bit more involved (but quite possible) to get that. but simple OO coding, like this, is not that hard |
| 2020-11-06 23:43:19 | → | nut joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) |
| 2020-11-06 23:43:43 | <cohn> | fixed: https://dpaste.org/cSsn |
| 2020-11-06 23:43:47 | → | da39a3ee5e6b4b0d joins (~textual@cm-171-98-70-75.revip7.asianet.co.th) |
| 2020-11-06 23:44:05 | × | dcoutts_ quits (~duncan@33.14.75.194.dyn.plus.net) (Ping timeout: 240 seconds) |
| 2020-11-06 23:44:06 | <ski> | that looks fine :) |
| 2020-11-06 23:44:33 | <cohn> | yea, I've briefly messed with UArray and STUArray |
| 2020-11-06 23:44:34 | <ski> | (fwiw, i think most of your round brackets are redundant) |
| 2020-11-06 23:44:39 | × | __monty__ quits (~toonn@unaffiliated/toonn) (Quit: leaving) |
| 2020-11-06 23:44:41 | ski | nods |
| 2020-11-06 23:44:56 | <cohn> | probably are but OCD is what it is. heh |
| 2020-11-06 23:45:40 | <ski> | (the only ones that aren't are the ones around `width+height') |
| 2020-11-06 23:45:45 | <cohn> | ya |
| 2020-11-06 23:45:57 | <ski> | any luck on the sum type version ? |
| 2020-11-06 23:46:10 | <cohn> | working on it now. |
| 2020-11-06 23:46:10 | → | britva joins (~britva@31-10-157-156.cgn.dynamic.upc.ch) |
| 2020-11-06 23:46:17 | <ski> | take your time |
| 2020-11-06 23:50:38 | <ski> | (btw, perhaps it's obvious, but if you wanted a method to take any additional parameters, you'd simply stuff a function into the corresponding field in the record) |
| 2020-11-06 23:51:32 | × | britva quits (~britva@31-10-157-156.cgn.dynamic.upc.ch) (Quit: This computer has gone to sleep) |
| 2020-11-06 23:52:04 | × | mdunnio quits (~mdunnio@208.59.170.5) (Remote host closed the connection) |
| 2020-11-06 23:52:11 | → | britva joins (~britva@31-10-157-156.cgn.dynamic.upc.ch) |
| 2020-11-06 23:54:16 | × | gehmehgeh quits (~ircuser1@gateway/tor-sasl/gehmehgeh) (Quit: Leaving) |
| 2020-11-06 23:54:18 | <cohn> | ok, sum type version: https://dpaste.org/5Fvz |
| 2020-11-06 23:54:31 | <cohn> | brb. |
| 2020-11-06 23:54:32 | → | lawr3nce joins (~lawr3nce@gateway/tor-sasl/lawr3nce) |
| 2020-11-06 23:55:02 | <cohn> | I added the `2` suffix since both types are defined in the same file. |
| 2020-11-06 23:56:20 | <ski> | yea, i figured |
| 2020-11-06 23:56:27 | <ski> | looks great ! :) |
| 2020-11-06 23:57:18 | × | dxld quits (~dxld@2a01:4f8:201:89ff:7479:df6a:7ab8:8305) (Quit: Bye) |
| 2020-11-06 23:57:39 | <ski> | now note how the "table" of the four alternative-property implementations ({circumference,area} * {circle,rectangle}) are distributed differently, in these two implementations |
| 2020-11-06 23:57:54 | → | argent0 joins (~argent0@168.227.98.85) |
| 2020-11-06 23:58:48 | → | olligobber joins (olligobber@gateway/vpn/privateinternetaccess/olligobber) |
| 2020-11-06 23:58:51 | <ski> | with the "alternative rows" `rectangle' and `circle' in the product (OO) version, and the "property columns" `circumference' and `area' in the sum ("FP") version |
| 2020-11-06 23:59:17 | <ski> | (and if you feel like it, you could try adding some new alternative, ior some new property) |
| 2020-11-06 23:59:24 | × | CodeAlways quits (uid272474@gateway/web/irccloud.com/x-urtbqxrwhpvhyukz) (Quit: Connection closed for inactivity) |
| 2020-11-06 23:59:30 | → | dxld joins (~dxld@80-109-136-248.cable.dynamic.surfer.at) |
| 2020-11-06 23:59:55 | <ski> | but, anyway, hopefully this small exercise gives you at least a somewhat better feel and understanding for the difference, the trade-off, i was mentioning above |
| 2020-11-07 00:00:01 | × | feedoo1 quits (~feedoo@178.239.168.171) () |
| 2020-11-07 00:00:14 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2020-11-07 00:02:12 | <ski> | (btw, note that nested pattern-matching for sum types, corresponds, dually, to constructing a nested record (constructing an object (implementing some interface), where some method also constructs some object (implementing some interface))) |
| 2020-11-07 00:02:52 | <ski> | oh .. and it would also be nice if one could use an alternative syntax for records, something like |
| 2020-11-07 00:03:05 | × | pfurla quits (~pfurla@ool-182ed2e2.dyn.optonline.net) (Ping timeout: 240 seconds) |
| 2020-11-07 00:03:34 | <ski> | codata Shape = Circumference :: Double & Area :: Double deriving Show |
| 2020-11-07 00:03:37 | <ski> | |
| 2020-11-07 00:03:46 | <ski> | rectangle :: Double -> Double -> Shape |
| 2020-11-07 00:04:11 | <ski> | #Circumference (rectangle w h) = 2 * (w + h) |
| 2020-11-07 00:04:35 | <ski> | #Area (rectangle w h) = w * h |
| 2020-11-07 00:04:55 | → | pfurla joins (~pfurla@64.145.79.100) |
| 2020-11-07 00:05:25 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 240 seconds) |
| 2020-11-07 00:05:25 | <ski> | (one might call this "message-dispatching" syntax (compare with pattern-matching syntax). the language Agda supports something like this, called "copatterns" there) |
| 2020-11-07 00:06:12 | <ski> | (`rectangle' is defined, above, in terms of what each field/method of a call to `rectangle' is to be) |
| 2020-11-07 00:07:14 | × | xff0x quits (~fox@2001:1a81:526d:d800:e0c1:ba75:a0ef:2a5b) (Ping timeout: 264 seconds) |
| 2020-11-07 00:13:47 | → | xff0x joins (~fox@2001:1a81:526d:d800:e0c1:ba75:a0ef:2a5b) |
| 2020-11-07 00:15:01 | × | Deide quits (~Deide@217.155.19.23) (Quit: Seeee yaaaa) |
All times are in UTC.