Code Monkey home page Code Monkey logo

Comments (5)

timjs avatar timjs commented on June 15, 2024

A simple sollution is using identity instead of empty like in:

import BasicPrelude hiding (empty)
import Control.Applicative (Alternative(..))
identity = mempty

It would be nice if this would be fixed in BasicPrelude itself!

from basic-prelude.

snoyberg avatar snoyberg commented on June 15, 2024

I'm quite happy with the current situation: the vast majority of packages use the term empty to mean mempty (bytestring, text, vector, containers, unordered-containers) and our goal is to fit the common use cases. I think Alternative is far less often used, and certainly its empty member even less so. I'd be happy to provide some export such as aempty = Control.Applicative.empty. For declaring instances, the conflict doesn't cause problems:

import Control.Applicative
import BasicPrelude
import Prelude ()

data Foo a

instance Applicative Foo where
    pure = undefined
    (<*>) = undefined

instance Functor Foo where
    fmap = undefined

instance Alternative Foo where
    empty = undefined
    (<|>) = undefined

from basic-prelude.

timjs avatar timjs commented on June 15, 2024

If it doesn't affect instance declaration -- I didn't know -- I totally agree with you. I think bare would be a nice synonym for Alternatvie.empty. The name is not used in most libraries (http://www.haskell.org/hoogle/?hoogle=bare), whereas void for instance is already taken. Alternative is used a lot in combination with parsers. Although most users only use Alternative.<|> and Alternative.many, I think it is nice to have access to it.

from basic-prelude.

singpolyma avatar singpolyma commented on June 15, 2024

I vote for aempty, but I'm also ok with identity

from basic-prelude.

DanBurton avatar DanBurton commented on June 15, 2024

I have a hard time seeing the Right Way for us to handle this issue, so I would trust @snoyberg's intuition on this one. As I understand it, the Maybe Monoid instance is the only thing to be concerned about. If we choose to export a synonym for Alternative.empty, it should not be identity, a valuable name that is way too general for Alternative to deserve.

from basic-prelude.

Related Issues (20)

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.