0 | module Cheerio.Utils
 1 |
 2 | -- import Data.List
 3 |
 4 | %foreign "node:lambda: (_, nothing, just, x) => { if (x === undefined) { return nothing } else { return just(x);}} "
 5 | prim_toMaybe : Maybe a -> (a -> Maybe a) -> a -> Maybe a
 6 |
 7 | export
 8 | primToMaybe : a -> Maybe a
 9 | primToMaybe x = prim_toMaybe Nothing Just x
10 |
11 | %foreign "node:lambda: (_, nil, cons, arr) => !Array.isArray(arr) ? nil : arr.reduce((acc,x) => cons(x)(acc), nil)"
12 | prim_arrayToList : List a -> (a -> List a -> List a) -> AnyPtr -> Ptr (List a)
13 |
14 | public export
15 | arrayToList : AnyPtr -> Ptr (List a)
16 | arrayToList x = prim_arrayToList Nil (::) x