Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: Detect current OS

Tags:

haskell

I'm currently writing a Haskell package. I want it to behave differently on Windows and Unix. What is the most "correct" way to detect what OS my code is being compiled on?

I did try using CPP and #ifdef _WIN32, but that doesn't appear to work at all.

Is there another macro? Can I get Cabal to tell me? Do I need to try something else entirely?

like image 744
MathematicalOrchid Avatar asked Apr 20 '14 14:04

MathematicalOrchid


1 Answers

You could use System.Info as defined in the base package here:

> :m + System.Info
> os
"darwin"
> arch
"i386"
like image 129
Lee Duhem Avatar answered Sep 19 '22 14:09

Lee Duhem