about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-16 17:14:30 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-07-16 17:14:30 +0200
commit4fc8799d38226363522e5711a645bfaea2b304ff (patch)
tree63d56eab66512c63e42929b90655b4b04ecc6d4f
parentEnable direnv and install hls (diff)
downloadsky-info-master.tar.gz
sky-info-master.tar.bz2
sky-info-master.zip
Have dependencies be managed by nix HEAD master
-rw-r--r--flake.nix2
-rw-r--r--shell.nix42
-rw-r--r--src/#Logic.hs#49
3 files changed, 82 insertions, 11 deletions
diff --git a/flake.nix b/flake.nix
index eb7865c..e850304 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,7 +9,7 @@
       (system:
         let pkgs = nixpkgs.legacyPackages.${system}; in
         {
-          devShells.default = import ./shell.nix { inherit pkgs; };
+          devShells.default = import ./shell.nix { nixpkgs = pkgs; };
         }
       );
 
diff --git a/shell.nix b/shell.nix
index 72fce48..1ab7f90 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,10 +1,32 @@
-{ pkgs ? import <nixpkgs> { } }:
-pkgs.mkShell {
-  buildInputs = with pkgs; [
-    ghc
-    cabal-install
-    stack
-  
-    haskell-language-server
-  ];
-}
+{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
+
+let
+
+  inherit (nixpkgs) pkgs;
+
+  f = { mkDerivation, astro, base, hpack, lib }:
+      mkDerivation {
+        pname = "sky-info";
+        version = "0.1.0.0";
+        src = ./.;
+        isLibrary = true;
+        isExecutable = true;
+        libraryHaskellDepends = [ astro base ];
+        libraryToolDepends = [ hpack ];
+        executableHaskellDepends = [ astro base ];
+        testHaskellDepends = [ astro base ];
+        prePatch = "hpack";
+        homepage = "https://github.com/githubuser/sky-info#readme";
+        license = lib.licenses.bsd3;
+      };
+
+  haskellPackages = if compiler == "default"
+                       then pkgs.haskellPackages
+                       else pkgs.haskell.packages.${compiler};
+
+  variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
+
+  drv = variant (haskellPackages.callPackage f {});
+
+in
+  drv.env
diff --git a/src/#Logic.hs# b/src/#Logic.hs#
new file mode 100644
index 0000000..25214ed
--- /dev/null
+++ b/src/#Logic.hs#
@@ -0,0 +1,49 @@
+module Logic where
+
+import Data.Astro.Types
+import Data.Astro.Time.JulianDate
+import Data.Astro.Coordinate
+import Data.Astro.Planet
+
+data SkyT = Sky { s_date :: JulianDate,
+                  objects :: [SkyObjectT]
+                  } deriving (Show)
+
+data RelativeSkyT = RelativeSky { rs_date :: JulianDate,
+                  nonVisibleObjects :: [SkyObjectT],
+                  visibleObjects :: [SkyObjectT]
+                  } deriving (Show)
+
+data SkyObjectT = SkyObject {
+    so_name :: String,
+    coordinates :: EquatorialCoordinates1
+} deriving (Show)
+
+data RelativeSkyObjectT = RelativeSkyObject {
+    rso_name :: String
+    --m_relative_coordinates :: HorizonCoordinates
+} deriving (Show)
+
+generateSky :: JulianDate -> SkyT
+generateSky date = Sky { 
+                            s_date = date,
+                            objects = predictSkyObjects date
+                        }
+
+trackedObjects :: [Planet]
+trackedObjects = [Mercury, Venus, Mars, Jupiter, Saturn, Neptune, Uranus] --Moon?
+
+predictSkyObjects :: JulianDate -> [SkyObjectT]
+predictSkyObjects date = do
+                            object <- trackedObjects
+                            objectDetails <- return $ j2010PlanetDetails object
+                            earthDetails <- return $ j2010PlanetDetails Earth
+                            objectPosition <- return $ planetPosition planetTrueAnomaly1 objectDetails earthDetails date
+                            return SkyObject { so_name = show object, coordinates = objectPosition }
+
+relativize_sky :: SkyT -> GeographicCoordinates -> RelativeSkyT
+relativize_sky sky location = RelativeSky {
+                                             rs_date = s_date sky,
+                                             nonVisibleObjects = objects sky,
+                                             visibleObjects = []
+                                          }λ> λ> 
\ No newline at end of file