Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undecorated Values in Expressions #8

Open
EarthCitizen opened this issue Jan 26, 2017 · 1 comment
Open

Undecorated Values in Expressions #8

EarthCitizen opened this issue Jan 26, 2017 · 1 comment
Labels
Milestone

Comments

@EarthCitizen
Copy link
Owner

EarthCitizen commented Jan 26, 2017

It would be convenient to do something like the following:

FgRed 5 <> " " <> FgWhite 6

New operator?

@EarthCitizen EarthCitizen changed the title mappend any ToEscapable without nesting in an Escapable Undecorated Values in Expressions Jan 26, 2017
@EarthCitizen EarthCitizen added this to the 1.2.0 milestone Jan 26, 2017
@EarthCitizen
Copy link
Owner Author

Probably will be />.

Example implementation for String:

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ExtendedDefaultRules #-}

import Data.Monoid ((<>))

default (Integer, Float)

class ToString a where
    toString :: a -> String

instance ToString Char where
    toString = (:[])

instance ToString Integer where
    toString = show

instance ToString Float where
    toString = show

instance ToString String where
    toString = id

infixr 6 />

(/>) :: (ToString a, ToString b) => a -> b -> String
(/>) a b = toString a <> toString b

main = do
    print $ "Hello " /> 5 /> " and " /> 7.3 /> " var " /> 'X'

@EarthCitizen EarthCitizen modified the milestones: 2.0.0, 1.2.0 Feb 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant