git.iko.soy/rowtype-yoga/purescript-native
on 71ebb7b help sign in
45 lines 1.3 kB history raw
1-----------------------------------------------------------------------------
2--
3-- Module : Language.PureScript.Names
4-- Copyright : (c) Phil Freeman 2013
5-- License : MIT
6--
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
9-- Portability :
10--
11-- |
12--
13-----------------------------------------------------------------------------
15{-# LANGUAGE DeriveDataTypeable #-}
17module Language.PureScript.Names where
19import Data.Data
21data Ident = Ident String | Op String deriving (Eq, Ord, Data, Typeable)
23instance Show Ident where
24 show (Ident s) = s
25 show (Op op) = '(':op ++ ")"
27newtype ProperName = ProperName { runProperName :: String } deriving (Eq, Ord, Data, Typeable)
29instance Show ProperName where
30 show = runProperName
32data ModuleName = ModuleName ProperName deriving (Eq, Ord, Data, Typeable)
34instance Show ModuleName where
35 show (ModuleName name) = show name
37data Qualified a = Qualified (Maybe ModuleName) a deriving (Eq, Ord, Data, Typeable)
39instance (Show a) => Show (Qualified a) where
40 show (Qualified Nothing a) = show a
41 show (Qualified (Just (ModuleName name)) a) = show name ++ "." ++ show a
43qualify :: ModuleName -> Qualified a -> (ModuleName, a)
44qualify m (Qualified Nothing a) = (m, a)
45qualify _ (Qualified (Just m) a) = (m, a)