Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A What does "parameterised type in the positive / negative position" mean in the context of invariant functors?

From PureScript's Data.Functor.Invariant documentation (emphasis mine): A type of functor that can be used to adapt the type of a wrapped function where the parameterised type occurs in both the...

1 answer  ·  posted 7mo ago by toraritte‭  ·  last activity 7mo ago by Derek Elkins‭

#1: Initial revision by user avatar toraritte‭ · 2024-06-02T18:11:26Z (7 months ago)
What does "parameterised type in the positive / negative position" mean in the context of invariant functors?
From PureScript's [`Data.Functor.Invariant`][1] documentation (emphasis mine):

> A type of functor that can be used to adapt the type of a wrapped function where **the parameterised type occurs in both the *positive* and *negative* position**, for example, `F (a -> a)`.

What do the terms "_positive_" and "_negative position_" refer to above?  
<sup>.. and also wondering why `F (a -> a)` requires an entirely new type of functor, but that should be another question probably..</sup>

I tried to figure this out both by learning more about invariant functors and looking up the terms "positive", "negative" in connection with functional programming, but wasn't able to connect the dots yet. Is there a basic resource that I've missed? Or, at least, where should one start to understand these concepts? (Not even sure what the right topic is; see my research attempts below.)

---

From the search results for 
  ["invariant functor positive negative"](https://www.google.com/search?q=invariant+functor+positive+negative&oq=invariant+functor+positive+negative&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORigATIHCAEQIRigATIHCAIQIRigATIHCAMQIRigAdIBCDU4NDFqMGo3qAIAsAIA&sourceid=chrome&ie=UTF-8)
, ["positively invariant vs negatively invariant polarity"](https://www.google.com/search?q=positively+invariant+vs+negatively+invariant+polarity&oq=positively+invariant+vs+negatively+invariant+polarity&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIHCAEQIRigATIHCAIQIRigATIHCAMQIRigATIHCAQQIRigAdIBCTEzNDMzajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8)
, ["type theory positive negative polarity invariant"](https://www.google.com/search?q=type+theory+positive+negative+polarity+invariant&oq=type+theory+positive+negative+polarity+invariant&gs_lcrp=EgZjaHJvbWUyCQgAEEUYORigAdIBCTExMTUyajBqN6gCALACAA&sourceid=chrome&ie=UTF-8)
, and ["what are invariant functors"](https://www.google.com/search?q=what+are+invariant+functors&oq=what+are+invariant+functors&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRhA0gEINDM0OWowajeoAgCwAgA):

+ [`nLab`] [polarity in type theory](https://ncatlab.org/nlab/show/polarity+in+type+theory)

  My intuition tells me this is the answer - but I have too little math / logic background to understand most of it (and to see how the parts that I do get connect to my question).

+ [`blog`] [Polarity in Type Theory](https://existentialtype.wordpress.com/2012/08/25/polarity-in-type-theory/)

  Same.

+ [`stackoverflow`] [Example of Invariant Functor?](https://stackoverflow.com/questions/22103445/example-of-invariant-functor)

  The answer does mention the words "positive" and "negative", but it doesn't explain them, and neither do the linked resources. It does mention "HOAS",

+ [`google search`] [higher order abstract syntax HOAS](https://www.google.com/search?q=higher+order+abstract+syntax+(HOAS)&sourceid=chrome&ie=UTF-8)

  but it doesn't look like what I'm looking for.


+ [`hackage`] [`layers` package documentation 
 -> invariant functors](https://hackage.haskell.org/package/layers-0.1/docs/Documentation-Layers-Overview.html#g:14)

  Even if it is relevant, I don't get it...

+ [`ploeh blog`] [Invariant functors](https://blog.ploeh.dk/2018/03/19/functors-applicatives-and-friends/) and [Functors as invariant functors](https://blog.ploeh.dk/2022/08/01/invariant-functors/)

  No mention of "_positive_" or "_negative_", but these posts did lead me to Mark Seemann's articles series [Functors, applicatives, and friends](https://blog.ploeh.dk/2018/03/19/functors-applicatives-and-friends/) that looks compelling and comprehensive, but so far I didn't find anything there either (or I missed it..)

+ [`nLab`] [invariant](https://ncatlab.org/nlab/show/invariant)

  Um, way above my head...


  [1]: https://pursuit.purescript.org/packages/purescript-invariant/6.0.0/docs/Data.Functor.Invariant