Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: lost a typeclass maybe? (Silent Leaf) 2. Re: lost a typeclass maybe? (Silent Leaf) 3. Re: lost a typeclass maybe? (Silent Leaf) 4. Re: lost a typeclass maybe? (Thomas Jakway) ---------------------------------------------------------------------- Message: 1 Date: Thu, 29 Jun 2017 20:38:01 +0200 From: Silent Leaf <silent.le...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] lost a typeclass maybe? Message-ID: <CAGFccjNLsvcDddvRUn33GD_KJUyW9iB6Tinj2++Uzz5=asx...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" well, i sent once more my message too early by mistake. when i say invent IO a b, i don't actually mean an IO type, i meant just, any type you can't manually unbox via pattern matching or otherwise. 2017-06-29 20:36 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > hi, > > i keep trying to find something that feels terribly obvious but i can't > make any link. > > say i have a function of the following type: > > foo :: (a, b) -> ([a], [b]) -> ([a], [b]) > or perhaps more generally: > foo :: SomeClass f => f a b -> f [a] [b] -> f [a] [b] > > is SomeClass supposed to be BiFunctor or something else? > clearly, what i want to do is to combine the elements of the first pair > into the elements of the second, preferrably without pattern matching, that > is, merely in function of (:). > > i think the problem with bifunctor is that it seems to only allow the > application of both arguments in a separate fashion. but here the first > argument is in one block, that is (a,b). > i know, ofc we could do something like: > foo pair pairList = bimap (fst pair :) (snd pair:) pairList > or maybe use curry or whatever. but i'd like my pair to not need to be > unboxed! > > is there not a way to not have to manually call fst and snd? are both of > these functions typeclass methods by any chance? then we could write a > generalized function that could work for any f = (:) or any kind of > pair-like thingy. mind you i'm not sure to which extent it would keep the > opacity of the type constructor (,). > > especially, it's a bit like unboxing the Maybe type constructor: you can > do it manually by pattern matching, but when you have the exact same issue > but with IO, it's not possible anymore to unbox the underlying type > equally, i bet one could invent IO a b, in a way that you could not just > get a and b, but you could somehow implement > opaqueBimap :: (i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b) > with here of course f = (,), k = [] or List, and (i -> k i) = (:) > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/49bbdff5/attachment-0001.html> ------------------------------ Message: 2 Date: Thu, 29 Jun 2017 20:44:56 +0200 From: Silent Leaf <silent.le...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] lost a typeclass maybe? Message-ID: <cagfccjotyquuenqhmjsp4vhuzgkykwmf_6p2bwvmnrk2tzk...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" ah, obviously, the first parameter is meant to be (i -> k i -> k i). mind you my opaqueBimap looks very peculiar... if i isolate half of f a b: Foo :: (i -> k i -> k i) -> f a -> f (k a) -> f (k a) Foo f fa fas = lift f fa fas so maybe i'd need a BiApplicative? 2017-06-29 20:38 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > well, i sent once more my message too early by mistake. > when i say invent IO a b, i don't actually mean an IO type, i meant just, > any type you can't manually unbox via pattern matching or otherwise. > > 2017-06-29 20:36 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > >> hi, >> >> i keep trying to find something that feels terribly obvious but i can't >> make any link. >> >> say i have a function of the following type: >> >> foo :: (a, b) -> ([a], [b]) -> ([a], [b]) >> or perhaps more generally: >> foo :: SomeClass f => f a b -> f [a] [b] -> f [a] [b] >> >> is SomeClass supposed to be BiFunctor or something else? >> clearly, what i want to do is to combine the elements of the first pair >> into the elements of the second, preferrably without pattern matching, that >> is, merely in function of (:). >> >> i think the problem with bifunctor is that it seems to only allow the >> application of both arguments in a separate fashion. but here the first >> argument is in one block, that is (a,b). >> i know, ofc we could do something like: >> foo pair pairList = bimap (fst pair :) (snd pair:) pairList >> or maybe use curry or whatever. but i'd like my pair to not need to be >> unboxed! >> >> is there not a way to not have to manually call fst and snd? are both of >> these functions typeclass methods by any chance? then we could write a >> generalized function that could work for any f = (:) or any kind of >> pair-like thingy. mind you i'm not sure to which extent it would keep the >> opacity of the type constructor (,). >> >> especially, it's a bit like unboxing the Maybe type constructor: you can >> do it manually by pattern matching, but when you have the exact same issue >> but with IO, it's not possible anymore to unbox the underlying type >> equally, i bet one could invent IO a b, in a way that you could not just >> get a and b, but you could somehow implement >> opaqueBimap :: (i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b) >> with here of course f = (,), k = [] or List, and (i -> k i) = (:) >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/15591d64/attachment-0001.html> ------------------------------ Message: 3 Date: Thu, 29 Jun 2017 20:51:30 +0200 From: Silent Leaf <silent.le...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] lost a typeclass maybe? Message-ID: <cagfccjpomh7odu00t-slhg2d6dq4vvqchmowxznzkyuxm6i...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" hey it does seem to exist, so that would be foo :: (BiApplicative f) :: (i -> k i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b) foo f fab fkakb = bipure f f <<$>> fab <<*>> fkakb pretty neat. i'm not sure the <<$>> operator exist, but the `ap` one does apparently. however i'm not sure that many people use BiApplicative ^^ But hey why not. don't pay attention to my code here, it's terribly typoed, i have no idea why i put the uppercase on the function Foo... 2017-06-29 20:44 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > ah, obviously, the first parameter is meant to be (i -> k i -> k i). > mind you my opaqueBimap looks very peculiar... > if i isolate half of f a b: > Foo :: (i -> k i -> k i) -> f a -> f (k a) -> f (k a) > Foo f fa fas = lift f fa fas > so maybe i'd need a BiApplicative? > > 2017-06-29 20:38 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > >> well, i sent once more my message too early by mistake. >> when i say invent IO a b, i don't actually mean an IO type, i meant just, >> any type you can't manually unbox via pattern matching or otherwise. >> >> 2017-06-29 20:36 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: >> >>> hi, >>> >>> i keep trying to find something that feels terribly obvious but i can't >>> make any link. >>> >>> say i have a function of the following type: >>> >>> foo :: (a, b) -> ([a], [b]) -> ([a], [b]) >>> or perhaps more generally: >>> foo :: SomeClass f => f a b -> f [a] [b] -> f [a] [b] >>> >>> is SomeClass supposed to be BiFunctor or something else? >>> clearly, what i want to do is to combine the elements of the first pair >>> into the elements of the second, preferrably without pattern matching, that >>> is, merely in function of (:). >>> >>> i think the problem with bifunctor is that it seems to only allow the >>> application of both arguments in a separate fashion. but here the first >>> argument is in one block, that is (a,b). >>> i know, ofc we could do something like: >>> foo pair pairList = bimap (fst pair :) (snd pair:) pairList >>> or maybe use curry or whatever. but i'd like my pair to not need to be >>> unboxed! >>> >>> is there not a way to not have to manually call fst and snd? are both of >>> these functions typeclass methods by any chance? then we could write a >>> generalized function that could work for any f = (:) or any kind of >>> pair-like thingy. mind you i'm not sure to which extent it would keep the >>> opacity of the type constructor (,). >>> >>> especially, it's a bit like unboxing the Maybe type constructor: you can >>> do it manually by pattern matching, but when you have the exact same issue >>> but with IO, it's not possible anymore to unbox the underlying type >>> equally, i bet one could invent IO a b, in a way that you could not just >>> get a and b, but you could somehow implement >>> opaqueBimap :: (i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b) >>> with here of course f = (,), k = [] or List, and (i -> k i) = (:) >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/c1e58478/attachment-0001.html> ------------------------------ Message: 4 Date: Thu, 29 Jun 2017 17:05:23 -0400 From: Thomas Jakway <tjak...@nyu.edu> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] lost a typeclass maybe? Message-ID: <CACZQfY-y=LV7Z-MvP+ELosgzi0Mwxqmi2WL1w_vhv1z=qdd...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" For what it's worth I think Bifunctors are more useful than one might think given the lack of attention they get. On Jun 29, 2017 2:51 PM, "Silent Leaf" <silent.le...@gmail.com> wrote: > hey it does seem to exist, so that would be > > foo :: (BiApplicative f) :: (i -> k i -> k i) -> f a b -> f (k a) (k b) -> > f (k a) (k b) > foo f fab fkakb = bipure f f <<$>> fab <<*>> fkakb > > pretty neat. i'm not sure the <<$>> operator exist, but the `ap` one does > apparently. > however i'm not sure that many people use BiApplicative ^^ But hey why not. > > don't pay attention to my code here, it's terribly typoed, i have no idea > why i put the uppercase on the function Foo... > > 2017-06-29 20:44 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: > >> ah, obviously, the first parameter is meant to be (i -> k i -> k i). >> mind you my opaqueBimap looks very peculiar... >> if i isolate half of f a b: >> Foo :: (i -> k i -> k i) -> f a -> f (k a) -> f (k a) >> Foo f fa fas = lift f fa fas >> so maybe i'd need a BiApplicative? >> >> 2017-06-29 20:38 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: >> >>> well, i sent once more my message too early by mistake. >>> when i say invent IO a b, i don't actually mean an IO type, i meant >>> just, any type you can't manually unbox via pattern matching or otherwise. >>> >>> 2017-06-29 20:36 GMT+02:00 Silent Leaf <silent.le...@gmail.com>: >>> >>>> hi, >>>> >>>> i keep trying to find something that feels terribly obvious but i can't >>>> make any link. >>>> >>>> say i have a function of the following type: >>>> >>>> foo :: (a, b) -> ([a], [b]) -> ([a], [b]) >>>> or perhaps more generally: >>>> foo :: SomeClass f => f a b -> f [a] [b] -> f [a] [b] >>>> >>>> is SomeClass supposed to be BiFunctor or something else? >>>> clearly, what i want to do is to combine the elements of the first pair >>>> into the elements of the second, preferrably without pattern matching, that >>>> is, merely in function of (:). >>>> >>>> i think the problem with bifunctor is that it seems to only allow the >>>> application of both arguments in a separate fashion. but here the first >>>> argument is in one block, that is (a,b). >>>> i know, ofc we could do something like: >>>> foo pair pairList = bimap (fst pair :) (snd pair:) pairList >>>> or maybe use curry or whatever. but i'd like my pair to not need to be >>>> unboxed! >>>> >>>> is there not a way to not have to manually call fst and snd? are both >>>> of these functions typeclass methods by any chance? then we could write a >>>> generalized function that could work for any f = (:) or any kind of >>>> pair-like thingy. mind you i'm not sure to which extent it would keep the >>>> opacity of the type constructor (,). >>>> >>>> especially, it's a bit like unboxing the Maybe type constructor: you >>>> can do it manually by pattern matching, but when you have the exact same >>>> issue but with IO, it's not possible anymore to unbox the underlying type >>>> equally, i bet one could invent IO a b, in a way that you could not >>>> just get a and b, but you could somehow implement >>>> opaqueBimap :: (i -> k i) -> f a b -> f (k a) (k b) -> f (k a) (k b) >>>> with here of course f = (,), k = [] or List, and (i -> k i) = (:) >>>> >>> >>> >> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/868afe4b/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 108, Issue 26 ******************************************