Skip to content

Add common PropName, AttrName, ClassName #30

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

Merged
merged 3 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Web/HTML.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Web.HTML

import Effect (Effect)
import Web.HTML.Window (Window)
import Web.HTML.Common (PropName, AttrName, ClassName) as Exports
import Web.HTML.History (History) as Exports
import Web.HTML.HTMLAnchorElement (HTMLAnchorElement) as Exports
import Web.HTML.HTMLAreaElement (HTMLAreaElement) as Exports
Expand Down
30 changes: 30 additions & 0 deletions src/Web/HTML/Common.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Web.HTML.Common where

import Prelude

import Data.Newtype (class Newtype)

-- | A wrapper for property names.
-- |
-- | The phantom type `value` describes the type of value which this property
-- | requires.
newtype PropName :: Type -> Type
newtype PropName value = PropName String

derive instance newtypePropName :: Newtype (PropName value) _
derive newtype instance eqPropName :: Eq (PropName value)
derive newtype instance ordPropName :: Ord (PropName value)

-- | A wrapper for attribute names.
newtype AttrName = AttrName String

derive instance newtypeAttrName :: Newtype AttrName _
derive newtype instance eqAttrName :: Eq AttrName
derive newtype instance ordAttrName :: Ord AttrName

-- | A wrapper for strings which are used as CSS classes.
newtype ClassName = ClassName String

derive instance newtypeClassName :: Newtype ClassName _
derive newtype instance eqClassName :: Eq ClassName
derive newtype instance ordClassName :: Ord ClassName