File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1+ /* global exports */
2+ "use strict" ;
3+
4+ // module Data.Either.Unsafe
5+
6+ exports . unsafeThrow = function ( msg ) {
7+ throw new Error ( msg ) ;
8+ } ;
Original file line number Diff line number Diff line change 1- module Data.Either.Unsafe where
1+ module Data.Either.Unsafe
2+ ( fromLeft
3+ , fromRight
4+ ) where
25
36import Prelude
47
@@ -8,9 +11,12 @@ import Data.Either
811-- | Passing a `Right` to `fromLeft` will throw an error at runtime.
912fromLeft :: forall a b . Either a b -> a
1013fromLeft (Left a) = a
14+ fromLeft _ = unsafeThrow " Data.Either.Unsafe.fromLeft called on Right value"
1115
1216-- | A partial function that extracts the value from the `Right` data constructor.
1317-- | Passing a `Left` to `fromRight` will throw an error at runtime.
1418fromRight :: forall a b . Either a b -> b
1519fromRight (Right a) = a
20+ fromRight _ = unsafeThrow " Data.Either.Unsafe.fromLeft called on Left value"
1621
22+ foreign import unsafeThrow :: forall a . String -> a
You can’t perform that action at this time.
0 commit comments