forked from purescript/trypurescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGithub.purs
More file actions
20 lines (16 loc) · 754 Bytes
/
Github.purs
File metadata and controls
20 lines (16 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Try.Github where
import Prelude
import Control.Monad.Cont.Trans (ContT(..))
import Control.Monad.Except.Trans (ExceptT(..))
import Data.Either (Either(..))
import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn3, mkEffectFn1, runEffectFn3)
-- | Fetch a raw file from a GitHub repo via raw.githubusercontent.com
foreign import getRawGithubFile_
:: EffectFn3 String
(EffectFn1 String Unit)
(EffectFn1 String Unit)
Unit
-- | A wrapper for `getRawGithubFile_` which uses `ContT`.
getRawGithubFile :: String -> ExceptT String (ContT Unit Effect) String
getRawGithubFile id_ = ExceptT (ContT \k -> runEffectFn3 getRawGithubFile_ id_ (mkEffectFn1 (k <<< Right)) (mkEffectFn1 (k <<< Left)))