src/Tools/Haskell/Haskell.thy
changeset 74203 92f08f3d77bd
parent 74197 1f78a40e4399
child 74204 c832f35ea571
equal deleted inserted replaced
74202:10455384a3e5 74203:92f08f3d77bd
   220 {-# LANGUAGE InstanceSigs #-}
   220 {-# LANGUAGE InstanceSigs #-}
   221 
   221 
   222 module Isabelle.Library (
   222 module Isabelle.Library (
   223   (|>), (|->), (#>), (#->),
   223   (|>), (|->), (#>), (#->),
   224 
   224 
   225   fold, fold_rev, single, map_index, get_index, separate,
   225   fold, fold_rev, single, the_single, map_index, get_index, separate,
   226 
   226 
   227   StringLike, STRING (..), TEXT (..), BYTES (..),
   227   StringLike, STRING (..), TEXT (..), BYTES (..),
   228   show_bytes, show_text,
   228   show_bytes, show_text,
   229 
   229 
   230   proper_string, enclose, quote, space_implode, commas, commas_quote, cat_lines,
   230   proper_string, enclose, quote, space_implode, commas, commas_quote, cat_lines,
   267 fold_rev _ [] y = y
   267 fold_rev _ [] y = y
   268 fold_rev f (x : xs) y = f x (fold_rev f xs y)
   268 fold_rev f (x : xs) y = f x (fold_rev f xs y)
   269 
   269 
   270 single :: a -> [a]
   270 single :: a -> [a]
   271 single x = [x]
   271 single x = [x]
       
   272 
       
   273 the_single :: [a] -> a
       
   274 the_single [x] = x
       
   275 the_single _ = undefined
   272 
   276 
   273 map_index :: ((Int, a) -> b) -> [a] -> [b]
   277 map_index :: ((Int, a) -> b) -> [a] -> [b]
   274 map_index f = map_aux 0
   278 map_index f = map_aux 0
   275   where
   279   where
   276     map_aux _ [] = []
   280     map_aux _ [] = []