11const { Box, Either, Right, Left, fromNullable } = require ( '../examples/lib' )
2-
32const { List } = require ( 'immutable-ext' )
4-
53const Task = require ( 'data.task' )
64
7-
8-
5+ // general isomorphism signature
96const Iso = ( to , from ) => ( {
107 to,
118 from
129} )
1310
11+ // isomorphisms String <-> Array
1412const chars = Iso (
1513 s => s . split ( '' ) ,
1614 c => c . join ( '' )
@@ -30,7 +28,10 @@ const truncate = str =>
3028 . concat ( '...' )
3129 )
3230
33- console . log ( truncate ( 'hello world' ) )
31+ console . log (
32+ 'hello world truncated is:' ,
33+ truncate ( 'hello world' )
34+ )
3435
3536
3637// [a] ~ Either null a
@@ -39,7 +40,7 @@ const singleton = Iso(
3940
4041 // Either into Array
4142 // 'fold' is used to extract value
42- e => e . fold ( ( ) => [ ] , x => [ x ] ) ,
43+ e => e . fold ( _ => [ ] , x => [ x ] ) ,
4344
4445 // Array into Either
4546 ( [ x ] ) => x ? Right ( x ) : Left ( )
@@ -48,8 +49,10 @@ const singleton = Iso(
4849// filtering Either type objects
4950// transform to Array, filter, than back to Either
5051const filterEither = ( e , pred ) =>
51- singleton . from (
52- singleton . to ( e )
52+ singleton
53+ . from (
54+ singleton
55+ . to ( e )
5356 . filter ( pred )
5457 )
5558
0 commit comments