git.iko.soy/rowtype-yoga/purescript-native
on 249ff93 help sign in
48 lines 1.4 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
20import Data.List (intercalate)
22data Ident = Ident String | Op String deriving (Eq, Ord, Data, Typeable)
24instance Show Ident where
25 show (Ident s) = s
26 show (Op op) = '(':op ++ ")"
28newtype ProperName = ProperName { runProperName :: String } deriving (Eq, Ord, Data, Typeable)
30instance Show ProperName where
31 show = runProperName
33data ModulePath = ModulePath [ProperName] deriving (Show, Eq, Ord, Data, Typeable)
35subModule :: ModulePath -> ProperName -> ModulePath
36subModule (ModulePath mp) name = ModulePath (mp ++ [name])
38global :: ModulePath
39global = ModulePath []
41data Qualified a = Qualified ModulePath a deriving (Eq, Ord, Data, Typeable)
43instance (Show a) => Show (Qualified a) where
44 show (Qualified (ModulePath names) a) = intercalate ":" (map show names ++ [show a])
46qualify :: ModulePath -> Qualified a -> (ModulePath, a)
47qualify mp (Qualified (ModulePath []) a) = (mp, a)
48qualify _ (Qualified mp a) = (mp, a)