generated from tpl/purs
fix: tuplecontaining instance (i think)
This commit is contained in:
parent
8c40a57d99
commit
0445113850
24
src/Data.Tuple.Containing.purs
Normal file
24
src/Data.Tuple.Containing.purs
Normal file
@ -0,0 +1,24 @@
|
||||
module Data.Tuple.Containing where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Data.Tuple (Tuple, fst, snd)
|
||||
import Data.Tuple.Nested (type (/\), (/\))
|
||||
|
||||
-- | given a tuple of any size with at least 1 value
|
||||
-- | of type `a`, `extract` the first occurence of `a`
|
||||
-- | from the tuple
|
||||
class TupleContaining a tup where
|
||||
extract :: tup -> a
|
||||
|
||||
instance TupleContaining a a where
|
||||
extract = identity
|
||||
else instance TupleContaining a (a /\ b) where
|
||||
extract = fst
|
||||
else instance TupleContaining b (a /\ b) where
|
||||
extract = snd
|
||||
else instance TupleContaining b (a /\ b /\ Unit) where
|
||||
extract (_ /\ b /\ _) = b
|
||||
else instance TupleContaining a tail => TupleContaining a (Tuple head tail) where
|
||||
extract (_ /\ tail) = extract tail
|
||||
|
@ -24,8 +24,7 @@ import Data.Map (Map)
|
||||
import Data.Map as Map
|
||||
import Data.Maybe (Maybe(..))
|
||||
import Data.Newtype (unwrap)
|
||||
import Data.Tuple (Tuple, fst, snd)
|
||||
import Data.Tuple.Nested (type (/\), (/\))
|
||||
import Data.Tuple.Containing (class TupleContaining, extract)
|
||||
import Effect (Effect)
|
||||
import Effect.Aff.Class (class MonadAff, liftAff)
|
||||
import Effect.Class (class MonadEffect, liftEffect)
|
||||
@ -102,23 +101,6 @@ data Method
|
||||
| DELETE
|
||||
| PATCH
|
||||
|
||||
-- | given a tuple of any size with at least 1 value
|
||||
-- | of type `a`, `extract` the first occurence of `a`
|
||||
-- | from the tuple
|
||||
class TupleContaining a tup where
|
||||
extract :: tup -> a
|
||||
|
||||
instance TupleContaining a a where
|
||||
extract = identity
|
||||
else instance TupleContaining a (a /\ b) where
|
||||
extract = fst
|
||||
else instance TupleContaining b (a /\ b) where
|
||||
extract = snd
|
||||
else instance TupleContaining b (a /\ b /\ Unit) where
|
||||
extract (_ /\ b /\ _) = b
|
||||
else instance TupleContaining a tail => TupleContaining a (Tuple head tail) where
|
||||
extract (_ /\ tail) = extract tail
|
||||
|
||||
class Request :: Type -> Constraint
|
||||
class Request a where
|
||||
requestUrl :: forall m. MonadAff m => a -> m URL
|
||||
|
Loading…
Reference in New Issue
Block a user