Git Product home page Git Product logo

Comments (6)

HeinrichApfelmus avatar HeinrichApfelmus commented on June 17, 2024

Looks intriguing!

Is it really necessary for the pattern synonym to be all caps?

Since which version of GHC are pattern synonyms supported? I would like to add a conditional to keep backwards compatibility with older compilers.

from operational.

Icelandjack avatar Icelandjack commented on June 17, 2024

The names I chose are tentative due to a chronic lack of imagination, conditional usage in lens

#if __GLASGOW_HASKELL__ >= 710
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
#endif
#if __GLASGOW_HASKELL__ >= 710
  -- * Pattern Synonyms
  , pattern Wrapped
  , pattern Unwrapped
#endif

(note pattern before the export)

#if __GLASGOW_HASKELL__ >= 710

pattern Wrapped a <- (view _Wrapped -> a) where
  Wrapped a = review _Wrapped a

pattern Unwrapped a <- (view _Unwrapped -> a) where
  Unwrapped a = review _Unwrapped a

#endif

from operational.

Icelandjack avatar Icelandjack commented on June 17, 2024

They may be made (explicitly) bidirectional like the Head pattern in the user guide

from operational.

HeinrichApfelmus avatar HeinrichApfelmus commented on June 17, 2024

Hm, I would very much like to name the patterns Return and Bind, of course. Unfortunately, these names are (essentially) already taken by the ProgramView type, so this would either have to break backward compatibility or introduce weird names for the patterns. I have to think about this.

from operational.

Icelandjack avatar Icelandjack commented on June 17, 2024

Returner and Binder?

from operational.

FranklinChen avatar FranklinChen commented on June 17, 2024

Any more thoughts about introducing pattern synonyms?

from operational.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.