Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,828
    • Issues 4,828
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 447
    • Merge requests 447
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16173

Closed
Open
Created Jan 13, 2019 by Dmitrii Kovanikov@chshersh

Move `Data.Profunctor` from `profunctors` package to `base`

Contravariant was added in GHC 8.6.

  • https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Functor-Contravariant.html

Profunctor also looks like fundamental abstraction to be worth considering adding to base.

Having both Profunctor and Choice typeclasses in the base library will also allow to write microprism package similar to microlens. Prisms often turns to be very useful since they allow to work nicely with sum types.

type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t)

Additional context for this ticket from Reddit:

  • https://www.reddit.com/r/haskell/comments/8v53cb/announce_ghc_861alpha1_available/e1o1giy/

It was proposed on Reddit to use QuantifiedConstraints for Profunctor. I'm not quite fluent with QuantifiedConstraints, but I think this may looks like this (mostly copy-pasting code from profunctors package):

{-# LANGUAGE QuantifiedConstraints #-}

class (forall a . Functor (p a)) => Profunctor p where
  {-# MINIMAL dimap | (lmap, rmap) #-}

  dimap :: (a -> b) -> (c -> d) -> p b c -> p a d
  dimap f g = lmap f . rmap g

  lmap :: (a -> b) -> p b c -> p a c
  lmap f = dimap f id

  rmap :: (b -> c) -> p a b -> p a c
  rmap = dimap id

instance Profunctor (->) where
  dimap ab cd bc = cd . bc . ab
  lmap = flip (.)
  rmap = (.)
Trac metadata
Trac field Value
Version 8.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Core Libraries
Test case
Differential revisions
BlockedBy
Related
Blocking
CC andrewthad, ekmett
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking