Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
Use StaticPointers for PairRDD
Browse files Browse the repository at this point in the history
Fixes tweag#119

This is caused by https://ghc.haskell.org/trac/ghc/ticket/14204 +
withStatic TH macro used to create instances in PairRDD module. The
bug results in `static` being allowed to be used with Tuple2
constructor without a compile-time error, which instead leads to a
run-time one. For example,

    swapPair :: Tuple2 a b -> Tuple2 b a
    swapPair (Tuple2 a b) = Tuple2 b a

    mapSwap :: ( Static (Reify a), Static (Reify b)
               , Static (Reflect a), Static (Reflect b)
               , Typeable a, Typeable b)
            => PairRDD a b
            -> IO (PairRDD b a)
    mapSwap rdd =
      PairRDD.fromRDD =<<
      RDD.map (closure (static swapPair)) =<<
      PairRDD.toRDD rdd

fails with

    sparkle-worker: GHC bug - makeStatic: Unresolved static form at line 107, column 1.
    CallStack (from HasCallStack):
      error, called at libraries/base/GHC/StaticPtr/Internal.hs:26:5 in base:GHC.StaticPtr.Internal
  • Loading branch information
dzhus committed Dec 12, 2017
1 parent d91782e commit 675c1f3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/Control/Distributed/Spark/PairRDD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StaticPointers #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
Expand Down

0 comments on commit 675c1f3

Please sign in to comment.