Cabal-2.0.1.0: A framework for packaging Haskell software

Copyright | Duncan Coutts 2007-2008
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell2010

Distribution.System

Contents

- Operating System
- Machine Architecture
- Platform is a pair of arch and OS
- Internal
- Classification

Description

Cabal often needs to do slightly different things on specific platforms. You probably know about the `os` however using that is very inconvenient because it is a string and different Haskell implementations do not agree on using the same strings for the same platforms! (In particular see the controversy over "windows" vs "mingw32"). So to make it more consistent and easy to use we have an `OS` enumeration.

Synopsis

- data OS
  - = Linux
  - | Windows
  - | OSX
  - | FreeBSD
  - | OpenBSD
  - | NetBSD
  - | DragonFly
  - | Solaris
  - | AIX
  - | HPUX
  - | IRIX
  - | HaLVM
  - | Hurd
  - | IOS
  - | Android
  - | Ghcjs
  - | OtherOS String
- buildOS :: OS
- data Arch
  - = I386
  - | X86_64
  - | PPC
  - | PPC64
  - | Sparc
  - | Arm
  - | Mips
  - | SH
  - | IA64
  - | S390
  - | Alpha
  - | Hppa
  - | Rs6000
  - | M68k
  - | Vax
  - | JavaScript
  - | OtherArch String
- buildArch :: Arch
- data Platform = Platform Arch OS
- buildPlatform :: Platform
- platformFromTriple :: String -> Maybe Platform
- knownOSs :: [OS]
- knownArches :: [Arch]
- data ClassificationStrictness
  - = Permissive
  - | Compat
  - | Strict
- classifyOS :: ClassificationStrictness -> String -> OS
- classifyArch :: ClassificationStrictness -> String -> Arch

# Operating System

data OS #

These are the known OS names: Linux, Windows, OSX ,FreeBSD, OpenBSD, NetBSD, DragonFly ,Solaris, AIX, HPUX, IRIX ,HaLVM ,Hurd ,IOS, Android,Ghcjs

The following aliases can also be used:, * Windows aliases: mingw32, win32, cygwin32 * OSX alias: darwin * Hurd alias: gnu * FreeBSD alias: kfreebsdgnu * Solaris alias: solaris2

Constructors

Linux |
Windows |
OSX |
FreeBSD |
OpenBSD |
NetBSD |
DragonFly |
Solaris |
AIX |
HPUX |
IRIX |
HaLVM |
Hurd |
IOS |
Android |
Ghcjs |
OtherOS String |

Instances

Eq OS # |
Methods (==) :: OS -> OS -> Bool # (/=) :: OS -> OS -> Bool #
Data OS # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OS -> c OS Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OS Source #

toConstr :: OS -> Constr Source #

dataTypeOf :: OS -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c OS) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OS) Source #

gmapT :: (forall b. Data b => b -> b) -> OS -> OS Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OS -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OS -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OS -> m OS Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OS -> m OS Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OS -> m OS Source #

Ord OS # |
Methods compare :: OS -> OS -> Ordering # (<) :: OS -> OS -> Bool # (<=) :: OS -> OS -> Bool # (>) :: OS -> OS -> Bool # (>=) :: OS -> OS -> Bool # max :: OS -> OS -> OS # min :: OS -> OS -> OS #
Read OS # |
Methods readsPrec :: Int -> ReadS OS Source # readList :: ReadS [OS] Source # readPrec :: ReadPrec OS Source # readListPrec :: ReadPrec [OS] Source #
Show OS # |
Methods showsPrec :: Int -> OS -> ShowS Source # show :: OS -> String Source # showList :: [OS] -> ShowS Source #
Generic OS # |
Associated Types type Rep OS :: * -> * Source # Methods from :: OS -> Rep OS x Source # to :: Rep OS x -> OS Source #
Binary OS # |
Methods put :: OS -> Put Source # get :: Get OS Source # putList :: [OS] -> Put Source #
Text OS # |
Methods disp :: OS -> Doc # parse :: ReadP r OS #
type Rep OS # |

type Rep OS = D1 * (MetaData "OS" "Distribution.System" "Cabal-2.0.1.0" False) ((:+:) * ((:+:) * ((:+:) * ((:+:) * (C1 * (MetaCons "Linux" PrefixI False) (U1 *)) (C1 * (MetaCons "Windows" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "OSX" PrefixI False) (U1 *)) (C1 * (MetaCons "FreeBSD" PrefixI False) (U1 *)))) ((:+:) * ((:+:) * (C1 * (MetaCons "OpenBSD" PrefixI False) (U1 *)) (C1 * (MetaCons "NetBSD" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "DragonFly" PrefixI False) (U1 *)) (C1 * (MetaCons "Solaris" PrefixI False) (U1 *))))) ((:+:) * ((:+:) * ((:+:) * (C1 * (MetaCons "AIX" PrefixI False) (U1 *)) (C1 * (MetaCons "HPUX" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "IRIX" PrefixI False) (U1 *)) (C1 * (MetaCons "HaLVM" PrefixI False) (U1 *)))) ((:+:) * ((:+:) * (C1 * (MetaCons "Hurd" PrefixI False) (U1 *)) (C1 * (MetaCons "IOS" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "Android" PrefixI False) (U1 *)) ((:+:) * (C1 * (MetaCons "Ghcjs" PrefixI False) (U1 *)) (C1 * (MetaCons "OtherOS" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * String))))))))

buildOS :: OS #

# Machine Architecture

data Arch #

These are the known Arches: I386, X86_64, PPC, PPC64, Sparc ,Arm, Mips, SH, IA64, S39, Alpha, Hppa, Rs6000, M68k, Vax and JavaScript.

The following aliases can also be used: * PPC alias: powerpc * PPC64 alias : powerpc64 * Sparc aliases: sparc64, sun4 * Mips aliases: mipsel, mipseb * Arm aliases: armeb, armel

Constructors

I386 |
X86_64 |
PPC |
PPC64 |
Sparc |
Arm |
Mips |
SH |
IA64 |
S390 |
Alpha |
Hppa |
Rs6000 |
M68k |
Vax |
JavaScript |
OtherArch String |

Instances

Eq Arch # |
Methods (==) :: Arch -> Arch -> Bool # (/=) :: Arch -> Arch -> Bool #
Data Arch # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Arch -> c Arch Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Arch Source #

toConstr :: Arch -> Constr Source #

dataTypeOf :: Arch -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Arch) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Arch) Source #

gmapT :: (forall b. Data b => b -> b) -> Arch -> Arch Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Arch -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Arch -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Arch -> m Arch Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Arch -> m Arch Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Arch -> m Arch Source #

Ord Arch # |
Methods compare :: Arch -> Arch -> Ordering # (<) :: Arch -> Arch -> Bool # (<=) :: Arch -> Arch -> Bool # (>) :: Arch -> Arch -> Bool # (>=) :: Arch -> Arch -> Bool # max :: Arch -> Arch -> Arch # min :: Arch -> Arch -> Arch #
Read Arch # |
Methods readsPrec :: Int -> ReadS Arch Source # readList :: ReadS [Arch] Source # readPrec :: ReadPrec Arch Source # readListPrec :: ReadPrec [Arch] Source #
Show Arch # |
Methods showsPrec :: Int -> Arch -> ShowS Source # show :: Arch -> String Source # showList :: [Arch] -> ShowS Source #
Generic Arch # |
Associated Types type Rep Arch :: * -> * Source # Methods from :: Arch -> Rep Arch x Source # to :: Rep Arch x -> Arch Source #
Binary Arch # |
Methods put :: Arch -> Put Source # get :: Get Arch Source # putList :: [Arch] -> Put Source #
Text Arch # |
Methods disp :: Arch -> Doc # parse :: ReadP r Arch #
type Rep Arch # |

type Rep Arch = D1 * (MetaData "Arch" "Distribution.System" "Cabal-2.0.1.0" False) ((:+:) * ((:+:) * ((:+:) * ((:+:) * (C1 * (MetaCons "I386" PrefixI False) (U1 *)) (C1 * (MetaCons "X86_64" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "PPC" PrefixI False) (U1 *)) (C1 * (MetaCons "PPC64" PrefixI False) (U1 *)))) ((:+:) * ((:+:) * (C1 * (MetaCons "Sparc" PrefixI False) (U1 *)) (C1 * (MetaCons "Arm" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "Mips" PrefixI False) (U1 *)) (C1 * (MetaCons "SH" PrefixI False) (U1 *))))) ((:+:) * ((:+:) * ((:+:) * (C1 * (MetaCons "IA64" PrefixI False) (U1 *)) (C1 * (MetaCons "S390" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "Alpha" PrefixI False) (U1 *)) (C1 * (MetaCons "Hppa" PrefixI False) (U1 *)))) ((:+:) * ((:+:) * (C1 * (MetaCons "Rs6000" PrefixI False) (U1 *)) (C1 * (MetaCons "M68k" PrefixI False) (U1 *))) ((:+:) * (C1 * (MetaCons "Vax" PrefixI False) (U1 *)) ((:+:) * (C1 * (MetaCons "JavaScript" PrefixI False) (U1 *)) (C1 * (MetaCons "OtherArch" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * String))))))))

buildArch :: Arch #

# Platform is a pair of arch and OS

data Platform #

Constructors

Platform Arch OS |

Instances

Eq Platform # |
Methods (==) :: Platform -> Platform -> Bool # (/=) :: Platform -> Platform -> Bool #
Data Platform # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Platform -> c Platform Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Platform Source #

toConstr :: Platform -> Constr Source #

dataTypeOf :: Platform -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Platform) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Platform) Source #

gmapT :: (forall b. Data b => b -> b) -> Platform -> Platform Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Platform -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Platform -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Platform -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Platform -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Platform -> m Platform Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Platform -> m Platform Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Platform -> m Platform Source #

Ord Platform # |
Methods compare :: Platform -> Platform -> Ordering # (<) :: Platform -> Platform -> Bool # (<=) :: Platform -> Platform -> Bool # (>) :: Platform -> Platform -> Bool # (>=) :: Platform -> Platform -> Bool # max :: Platform -> Platform -> Platform # min :: Platform -> Platform -> Platform #
Read Platform # |
Methods readsPrec :: Int -> ReadS Platform Source # readList :: ReadS [Platform] Source # readPrec :: ReadPrec Platform Source # readListPrec :: ReadPrec [Platform] Source #
Show Platform # |
Methods showsPrec :: Int -> Platform -> ShowS Source # show :: Platform -> String Source # showList :: [Platform] -> ShowS Source #
Generic Platform # |
Associated Types type Rep Platform :: * -> * Source # Methods from :: Platform -> Rep Platform x Source # to :: Rep Platform x -> Platform Source #
Binary Platform # |
Methods put :: Platform -> Put Source # get :: Get Platform Source # putList :: [Platform] -> Put Source #
Text Platform # |
Methods disp :: Platform -> Doc # parse :: ReadP r Platform #
type Rep Platform # |
type Rep Platform = D1 * (MetaData "Platform" "Distribution.System" "Cabal-2.0.1.0" False) (C1 * (MetaCons "Platform" PrefixI False) ((:*:) * (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Arch)) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * OS))))

buildPlatform :: Platform #

The platform Cabal was compiled on. In most cases, `LocalBuildInfo.hostPlatform` should be used instead (the platform we're targeting).

platformFromTriple :: String -> Maybe Platform #

# Internal

knownOSs :: [OS] #

knownArches :: [Arch] #

# Classification

data ClassificationStrictness #

How strict to be when classifying strings into the `OS` and `Arch` enums.

The reason we have multiple ways to do the classification is because there are two situations where we need to do it.

For parsing OS and arch names in .cabal files we really want everyone to be referring to the same or or arch by the same name. Variety is not a virtue in this case. We don't mind about case though.

For the System.Info.os/arch different Haskell implementations use different names for the same or/arch. Also they tend to distinguish versions of an OS/arch which we just don't care about.

The `Compat` classification allows us to recognise aliases that are already in common use but it allows us to distinguish them from the canonical name which enables us to warn about such deprecated aliases.

Constructors

Permissive |
Compat |
Strict |

classifyOS :: ClassificationStrictness -> String -> OS #

classifyArch :: ClassificationStrictness -> String -> Arch #